Skip to content

Instantly share code, notes, and snippets.

@lav45
Last active December 29, 2018 00:46
Show Gist options
  • Save lav45/deba96b72f777755f5f511f7f3b29adb to your computer and use it in GitHub Desktop.
Save lav45/deba96b72f777755f5f511f7f3b29adb to your computer and use it in GitHub Desktop.
server {
listen 80;
index index.php;
server_name site.com admin.site.net;
client_max_body_size 32m;
client_body_buffer_size 32m;
charset utf-8;
gzip on;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
rewrite (.+)/$ $1 redirect;
set $base_root /var/www/site;
set $base_path frontend;
if ( $host ~ ^admin ) {
set $base_path backend;
}
root $base_root/$base_path/web;
# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
try_files $uri =404;
}
# CSS and Javascript
location ~* \.(?:css|js)$ {
expires 1y;
access_log off;
add_header Cache-Control "public";
try_files $uri =404;
}
location / {
try_files $uri /index.php$is_args$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SERVER_NAME $host;
internal;
}
location = /robots.txt { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }
location ~* /CHANGELOG { access_log off; log_not_found off; deny all; }
location ~* /LICENSE { access_log off; log_not_found off; deny all; }
location ~* /README { access_log off; log_not_found off; deny all; }
location ~* /\. { access_log off; log_not_found off; deny all; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment