Skip to content

Instantly share code, notes, and snippets.

@core01
Created October 28, 2015 13:03
Show Gist options
  • Save core01/90751a8b888c3a6991ad to your computer and use it in GitHub Desktop.
Save core01/90751a8b888c3a6991ad to your computer and use it in GitHub Desktop.
NGINX site config
upstream backend-site {server unix:/var/run/php5-site.sock;}
server {
server_name www.site.ru;
return 301 http://site.ru$request_uri;
}
server {
listen 80;
client_max_body_size 32m;
error_log /var/www/user/site.ru/logs/error.log;
access_log /var/www/user/site.ru/logs/access.log;
root /var/www/user/site.ru/www;
index index.php index.html index.htm;
rewrite_log on;
server_name site.ru;
include includes/allowedips;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri $uri/ @rewrite;
}
location @rewrite {
rewrite ^/(.*)$ /index.php?q=$1;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
#fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass backend-site;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_busy_buffers_size 25k;
fastcgi_temp_file_write_size 256k;
include fastcgi_params;
}
location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|bmp)$ {
access_log off;
log_not_found off;
expires 30d;
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment