Skip to content

Instantly share code, notes, and snippets.

@mvrhov
Created April 13, 2011 08:33
Show Gist options
  • Save mvrhov/917200 to your computer and use it in GitHub Desktop.
Save mvrhov/917200 to your computer and use it in GitHub Desktop.
nginx über config
server {
listen 80;
server_name <your.site.com>;
root /var/www/vhosts/<your.site.com>/site/www/;
#site root is redirected to the app boot script
location = / {
try_files @site @site;
}
#all other locations try other files first and go to our front controller if none of them exists
location / {
try_files $uri $uri/ @site;
}
# deny access to .htaccess, .svn .bzr .git files
location ~ /\.(ht|svn|bzr|git) {
deny all;
}
#return 404 for all php files as we do have a front controller
location ~ \.php$ {
return 404;
}
location @site {
fastcgi_pass unix:/var/run/php-fpm/www.sock;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_ignore_client_abort on;
#cache up to 256k, also sets headers size cache to 16k
fastcgi_buffers 16 16k;
#uncomment if your headers are more than 16k (e.g. huge cookies)
#fastcgi_buffer_size 32k;
#uncomment when running via htps
#fastcgi_param HTTPS on;
include fastcgi_params;
}
}
server {
listen 80;
server_name <your.site.com>;
access_log /var/log/nginx/<your.site.com>.access.log;
error_log /var/log/nginx/<your.site.com>.error.log;
index index.html index.htm index.php;
gzip on;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/xml application/xml application/xml+rss text/css text/javascript application/javascript application/x-javascript application/json;
gzip_disable "MSIE [1-6]\.";
gzip_static on;
gzip_buffers 32 8k;
set $page_root /var/www/vhosts/<your.site.com>;
root $page_root/site/www/;
#site root is redirected to the app boot script
location = / {
try_files @site @site;
}
#all other locations try other files first and go to our front controller if none of them exists
location / {
try_files $uri $uri/ @site;
}
#in application you do this "X-Accel-Redirect: /storage/<file name>"
location /storage/ {
internal;
root $page_root/storage/;
}
#error pages redirects to static htmls
error_page 403 /403.html;
location = /403.html {
root /var/www/default-pages;
}
error_page 404 /404.html;
location = /404.html {
root /var/www/default-pages;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/default-pages;
}
# deny access to .htaccess, .svn .bzr .git files
location ~ /\.(ht|svn|bzr|git) {
deny all;
}
# Support for various "default" files that should reside in a documen root.
# We return a 204 (No Content) if such file doesn't exist.
location = /favicon.ico {
try_files /favicon.ico =204;
}
location = /apple-touch-icon.png {
try_files /apple-touch-icon.png =204;
}
location = /robots.txt {
try_files /robots.txt =204;
}
location = /sitemap.xml {
try_files /sitemap.xml =204;
}
#return 404 for all php files as we do have a front controller
location ~ \.php$ {
return 404;
}
#uncomment in production
#location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
# expires 7d;
# log_not_found off;
#}
location @site {
fastcgi_pass unix:/var/run/php-fpm/www.sock;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_ignore_client_abort on;
#cache up to 256k, also sets headers size cache to 16k
fastcgi_buffers 16 16k;
#uncomment if your headers are more than 16k (e.g. huge cookies)
#fastcgi_buffer_size 32k;
#comment in production
fastcgi_param APPLICATION_ENV development;
#uncomment when running via htps
#fastcgi_param HTTPS on;
include fastcgi_params;
}
}
@maddy2101
Copy link

and now I would be interested, what value @site might have ... thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment