Skip to content

Instantly share code, notes, and snippets.

@pavelnunez
Last active March 23, 2017 18:12
Show Gist options
  • Save pavelnunez/52feeb5cb650a37c89c96adcc6bc1b60 to your computer and use it in GitHub Desktop.
Save pavelnunez/52feeb5cb650a37c89c96adcc6bc1b60 to your computer and use it in GitHub Desktop.
Nginx settings and rules for Symfony 3.x on Ubuntu / Debian
server {
listen 8080;
server_name www.domain.local domain.local;
root /var/www/html/domain/web;
index index.html index.htm index.php;
access_log /var/log/nginx/domain.local.access.log;
access_log /var/log/nginx/domain.local.apachestyle.access.log apachestandard;
error_log /var/log/nginx/domain.local.error.log;
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
location = /apple-touch-icon.png { access_log off; log_not_found off; }
location = /apple-touch-icon-precomposed.png { access_log off; log_not_found off; }
location ~ /\. { deny all; access_log off; log_not_found off; }
location / {
try_files $uri /app.php$is_args$args;
}
# DEV
# Development environment rules
location ~ ^/(app_dev|config)\.php(/|$) {
proxy_intercept_errors on;
error_page 500 501 502 503 = @fallback;
fastcgi_buffers 8 256k;
fastcgi_buffer_size 128k;
fastcgi_intercept_errors on;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_pass hhvm;
}
# PROD
# Production environment rules
location ~ ^/app\.php(/|$) {
proxy_intercept_errors on;
error_page 500 501 502 503 = @fallback;
fastcgi_buffers 8 256k;
fastcgi_buffer_size 128k;
fastcgi_intercept_errors on;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_pass hhvm;
}
location @fallback {
fastcgi_buffers 8 256k;
fastcgi_buffer_size 128k;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass php;
}
location ~* \.(ico|gif|jpe?g|png|svg|eot|otf|woff|woff2|ttf|ogg)$ {
expires max;
}
location ~ \.php$ {
return 404;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment