Skip to content

Instantly share code, notes, and snippets.

@fstrube
Last active March 17, 2021 10:52
Show Gist options
  • Save fstrube/4404017 to your computer and use it in GitHub Desktop.
Save fstrube/4404017 to your computer and use it in GitHub Desktop.
nginx-magento
server {
listen 80;
root /var/www/magento;
index index.php index.html index.htm;
server_name magento.local;
# Place PHP error logs in the Magento log folder
set $php_log /var/www/magento/var/log/php_errors.log;
# Replaces Apache rewrite rules
location / {
try_files $uri $uri/ @handler;
}
# Protect sensitive folders
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; }
# Protect dotfiles (htaccess, svn, etc.)
location /. { return 404; }
location @handler {
rewrite / /index.php;
}
# Remove trailing slashes from PHP files
location ~ .php/ {
rewrite ^(.*.php)/ $1 last;
}
# Pass PHP to a the PHP-FPM backend
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
#fastcgi_param HTTPS $fastcgi_https;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param MAGE_IS_DEVELOPER_MODE on; # Turn on developer mode
#fastcgi_param MAGE_RUN_CODE $mage_run_code;
#fastcgi_param MAGE_RUN_TYPE $mage_run_type;
fastcgi_param PHP_VALUE error_log=$php_log;
include fastcgi_params;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment