Skip to content

Instantly share code, notes, and snippets.

@dhargitai
Created August 11, 2015 19:24
Show Gist options
  • Save dhargitai/08a342bae616f158111f to your computer and use it in GitHub Desktop.
Save dhargitai/08a342bae616f158111f to your computer and use it in GitHub Desktop.
root@web1:/var/www/szepul.hu# cat /etc/nginx/sites-enabled/default
server {
charset utf-8;
client_max_body_size 128M;
listen 80;
server_name szepul.hu.dev www.szepul.hu.dev;
root /var/www/szepul.hu/web;
index app_dev.php;
fastcgi_read_timeout 1800;
location / {
# try to serve file directly, fallback to app.php
try_files $uri /app_dev.php$is_args$args;
}
# Other environments than production
# This rule should only be placed on your development environment
# In production, don't include this and don't deploy app_dev.php or config.php
location ~ ^/(app_dev|app_test|config)\.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# uncomment to avoid processing of calls to non-existing static files by Yii
location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
try_files $uri =404;
}
# Production environment
location ~ ^/app\.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# Prevents URIs that include the front controller. This will 404:
# http://domain.tld/app.php/some-path
# Remove the internal directive to allow URIs like this
internal;
}
location ~ /\.(ht|svn|git) {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment