Skip to content

Instantly share code, notes, and snippets.

@mickgeek
Created December 17, 2018 11:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mickgeek/c793f65fdf5036fd36a1d3963069a95c to your computer and use it in GitHub Desktop.
Save mickgeek/c793f65fdf5036fd36a1d3963069a95c to your computer and use it in GitHub Desktop.
server {
listen 80;
server_name magento.olegbelostotsky.com;
root /srv/www/magento.olegbelostotsky.com;
location / {
index index.html index.php;
try_files $uri $uri/ @handler;
expires max;
}
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; }
## Allow admins only to view export directory
## Set up the password for any username using this command:
## htpasswd -c /etc/nginx/htpasswd magentoadmin
location /var/export/ {
auth_basic "Restricted";
auth_basic_user_file htpasswd; ## Defined at /etc/nginx/htpassword
autoindex on;
}
## Disable .htaccess and other hidden files
location /. {
return 404;
}
## Magento uses a common front handler
location @handler {
rewrite / /index.php;
}
## Forward paths like /js/index.php/x.js to relevant handler
location ~ .php/ {
rewrite ^(.*.php)/ $1 last;
}
## php-fpm parsing
location ~ .php$ {
## Catch 404s that try_files miss
if (!-e $request_filename) { rewrite / /index.php last; }
## Disable cache for php files
expires off;
## Socket configuration
fastcgi_pass php-fpm-upstream;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
## Store code is located at Administration > Configuration > Manage Stores in your Magento Installation.
fastcgi_param MAGE_RUN_CODE default;
fastcgi_param MAGE_RUN_TYPE store;
## Tweak fastcgi buffers, just in case.
fastcgi_buffer_size 128k;
fastcgi_buffers 256 4k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment