Created
January 23, 2015 07:38
-
-
Save rexey3s/5e46725f79934787af50 to your computer and use it in GitHub Desktop.
nginx/sites-available
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# You should look at the following URL's in order to grasp a solid understanding | |
# of Nginx configuration files in order to fully unleash the power of Nginx. | |
# http://wiki.nginx.org/Pitfalls | |
# http://wiki.nginx.org/QuickStart | |
# http://wiki.nginx.org/Configuration | |
# | |
# Generally, you will want to move this file somewhere, and start with a clean | |
# file but keep this around for reference. Or just disable in sites-enabled. | |
# | |
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples. | |
## | |
# Default server configuration | |
# | |
server { | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
# SSL configuration | |
# | |
# listen 443 ssl default_server; | |
# listen [::]:443 ssl default_server; | |
# | |
# Self signed certs generated by the ssl-cert package | |
# Don't use them in a production server! | |
# | |
# include snippets/snakeoil.conf; | |
root /var/www/html; | |
# Add index.php to the list if you are using PHP | |
index index.php index.html index.htm index.nginx-debian.html; | |
server_name localhost; | |
# location / { | |
# # First attempt to serve request as file, then | |
# # as directory, then fall back to displaying a 404. | |
# try_files $uri $uri/ =404 /index.html; | |
# } | |
location ~* /\.ht { | |
deny all; | |
access_log off; | |
log_not_found off; | |
} | |
set $cache_uri $request_uri; | |
if ($request_method = POST) { | |
set $cache_uri 'null cache'; | |
} | |
if ($query_string != "") { | |
set $cache_uri 'null cache'; | |
} | |
location = /favicon.ico { log_not_found off; access_log off; } | |
location = /robots.txt { log_not_found off; access_log off; } | |
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { add_header "" ""; } | |
location ~ "^/ngx_pagespeed_static/" { } | |
location ~ "^/ngx_pagespeed_beacon$" { } | |
location /ngx_pagespeed_statistics { allow 127.0.0.1; deny all; } | |
location /ngx_pagespeed_global_statistics { allow 127.0.0.1; deny all; } | |
location /ngx_pagespeed_message { allow 127.0.0.1; deny all; } | |
location /pagespeed_console { allow 127.0.0.1; deny all; } | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; | |
} | |
if (!-e $request_filename) { | |
rewrite ^/(.+)/$ /index.php?/$1 last; | |
break; | |
} | |
location ~* \.(?:ico|css|js|jpe?g|JPG|png|svg|woff)$ { | |
expires 365d; | |
} | |
location ~ \.php(.*)$ { | |
set $skip_cache 1; | |
if ($cache_uri != "null cache") { | |
add_header X-Cache_Debug "$cache_uri $cookie_nocache $arg_nocache$arg_comment $http_pragma $http_authorization"; | |
set $skip_cache 0; | |
} | |
fastcgi_cache_bypass $skip_cache; | |
fastcgi_cache microcache; | |
fastcgi_cache_key $scheme$host$request_uri$request_method; | |
fastcgi_cache_valid any 8m; | |
fastcgi_cache_bypass $http_pragma; | |
fastcgi_cache_use_stale updating error timeout invalid_header http_500; | |
fastcgi_pass unix:/usr/share/php/var/run/php5-fpm.sock; | |
try_files $uri = 404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
} | |
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 | |
# | |
# location ~ \.php$ { | |
# include snippets/fastcgi-php.conf; | |
# | |
# # With php5-cgi alone: | |
# fastcgi_pass 127.0.0.1:9000; | |
# # With php5-fpm: | |
# fastcgi_pass unix:/usr/share/php/var/run/php5-fpm.sock; | |
# fastcgi_index index.php; | |
# include fastcgi_params; | |
# fastcgi_param SERVER_NAME $http_host; | |
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
# fastcgi_ignore_client_abort on; | |
# } | |
# deny access to .htaccess files, if Apache's document root | |
# concurs with nginx's one | |
# | |
#location ~ /\.ht { | |
# deny all; | |
#} | |
} | |
# Virtual Host configuration for example.com | |
# | |
# You can move that to a different file under sites-available/ and symlink that | |
# to sites-enabled/ to enable it. | |
# | |
#server { | |
# listen 80; | |
# listen [::]:80; | |
# | |
# server_name example.com; | |
# | |
# root /var/www/example.com; | |
# index index.html; | |
# | |
# location / { | |
# try_files $uri $uri/ =404; | |
# } | |
#} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment