Created
January 12, 2016 14:33
-
-
Save aguimaraes/2e5a44605265d07ff4bf to your computer and use it in GitHub Desktop.
nginx config for magento
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| server { | |
| # Listen on port 80 | |
| listen 80; | |
| server_name magento; | |
| # Path to the files in which you wish to | |
| # store your access and error logs. | |
| access_log /var/log/nginx/magento.access.log; | |
| error_log /var/log/nginx/magento.error.log; | |
| root /srv/magento; | |
| location / { | |
| index index.html index.php; | |
| try_files $uri $uri/ @handler; | |
| } | |
| # Deny access to specific directories no one | |
| # in particular needs access to anyways. | |
| 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 only those who have a login name and password | |
| # to view the export folder. Refer to /etc/nginx/htpassword. | |
| location /var/export/ { | |
| auth_basic "Restricted"; | |
| auth_basic_user_file htpasswd; | |
| autoindex on; | |
| } | |
| # Deny all attempts to access hidden files | |
| # such as .htaccess, .htpasswd, etc... | |
| location ~ /\. { | |
| deny all; | |
| access_log off; | |
| log_not_found off; | |
| } | |
| # This redirect is added so to use Magentos | |
| # common front handler when handling incoming URLs. | |
| location @handler { | |
| rewrite / /index.php; | |
| } | |
| # Forward paths such as /js/index.php/x.js | |
| # to their relevant handler. | |
| location ~ .php/ { | |
| rewrite ^(.*.php)/ $1 last; | |
| } | |
| # Handle the exectution of .php files. | |
| location ~ .php$ { | |
| if (!-e $request_filename) { | |
| rewrite / /index.php last; | |
| } | |
| expires off; | |
| fastcgi_pass unix:/var/run/php5-fpm.sock; | |
| fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
| fastcgi_param MAGE_RUN_CODE default; | |
| fastcgi_param MAGE_RUN_TYPE store; | |
| fastcgi_param MAGE_IS_DEVELOPER_MODE true; | |
| include fastcgi_params; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment