Create a gist now

Instantly share code, notes, and snippets.

What would you like to do? /etc/nginx/conf.d/nginx.conf
server {
listen 8080;
root /var/www/;
index index.php index.html index.htm;
# XML Sitemap
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;
# enforce www (exclude certain subdomains)
#if ($host !~* ^(www|subdomain))
# rewrite ^/(.*)$ $scheme://www.$host/$1 permanent;
# enforce NO www
if ($host ~* ^www\.(.*))
set $host_without_www $1;
rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
# unless the request is for a valid file, send to bootstrap
if (!-e $request_filename)
rewrite ^(.+)$ /index.php?q=$1 last;
# catch all
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
# Directives to send expires headers and turn off 404 error logging.
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off;
log_not_found off;
expires 30d;
# deny access to apache .htaccess files
location ~ /\.ht
deny all;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment