Skip to content

Instantly share code, notes, and snippets.

@davidrushton
Created June 2, 2016 14:24
Show Gist options
  • Save davidrushton/0b2232df1c1681e9ad107a4ec64e53dd to your computer and use it in GitHub Desktop.
Save davidrushton/0b2232df1c1681e9ad107a4ec64e53dd to your computer and use it in GitHub Desktop.
server {
listen 80;
## SSL directives might go here
## see http://www.howtoforge.com/how_to_set_up_ssl_vhosts_under_nginx_plus_sni_support_ubuntu_11.04_debian_squeeze
## if you want to enable SSL for this vhost
#server_name website.com *.website.com;
root /home/vagrant/public;
## rewrites example.com to www.example.com
#if ($http_host != "website.com") {
# rewrite ^ $scheme://website.com$request_uri permanent;
#}
location / {
index index.html index.php; ## Allow a static html file to be shown first
try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
expires 30d; ## Assume all files are cachable
}
## These locations would be hidden by .htaccess normally
location /app/ { deny all; }
location /includes/ { deny all; }
location /lib/ { deny all; }
location /media/downloadable/ { deny all; }
location /pkginfo/ { deny all; }
location /report/config.xml { deny all; }
location /var/ { deny all; }
location /var/export/ { ## Allow admins only to view export folder
auth_basic "Restricted"; ## Message shown in login window
auth_basic_user_file /var/www/website.com/.htpasswd; ## See /etc/nginx/htpassword
autoindex on;
}
## Disable .htaccess and other hidden files
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location @handler { ## Magento uses a common front handler
rewrite /(../)? /$1index.php?$args;
}
location ~ \.php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*\.php)/ $1 last;
}
location ~ \.php$ { ## Execute PHP scripts
if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
expires off; ## Do not cache dynamic content
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE admin;
fastcgi_param MAGE_RUN_TYPE store;
include fastcgi_params; ## See /etc/nginx/fastcgi_params
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment