Skip to content

Instantly share code, notes, and snippets.

@tarnus
Created April 2, 2014 13:06
Show Gist options
  • Save tarnus/9933690 to your computer and use it in GitHub Desktop.
Save tarnus/9933690 to your computer and use it in GitHub Desktop.
Sample nginx config
server {
listen 80;
server_name shoptest.snethosting.com;
access_log /var/log/nginx/shoptest.snethosting.com.access.log;
root /home/shoptest;
index index.php;
location / {
try_files $uri $uri/ @drupal;
}
location @drupal {
rewrite ^(.+)$ /index.php$1 last;
}
location @rewrite {
# You have 2 options here
# For D7 and above:
# Clean URLs are handled in drupal_environment_initialize().
rewrite ^ /index.php;
# For Drupal 6 and bwlow:
# Some modules enforce no slash (/) at the end of the URL
# Else this rewrite block wouldn't be needed (GlobalRedirect)
#rewrite ^/(.*)$ /index.php?q=$1;
}
# Fighting with Styles? This little gem is amazing.
# This is for D6
#location ~ ^/sites/.*/files/imagecache/ {
# This is for D7 and D8
location ~ ^/sites/.*/files/styles/ {
try_files $uri @rewrite;
}
location ~ .php {
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
access_log off;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment