/
Pack Hosting Panel

Magento 1 Nginx configuration

Which Nginx configuration is recommended for Magento 1?


Magento 1 Nginx configurations

In this article we will explain how to set up a basic configuration in Nginx for your Magento 1 shop. We will explain how to shield sensitive locations within your Magento shop from the outside.

Shield sensitive locations

When you have a [Magento shop] of course, you will benefit from a [secured webshop]. Within Magento, there are several locations that do not have to be accessible from the outside, so we like to shield them for that reason. We have already prepared this configuration for you. The configuration only has to be enabled, below we will explain how to do it:

Log in to the environment

Log in with SSH to the concerned environment.

Navigate to the location of the file

As soon as you are logged in, you can navigate to the concerned location. The file is named 'magento.nginx.conf' and can be found at /home/<username>/domains/<domainname>/var/etc/magento.nginx.conf

Enable the Magento 1 configuration

Enable the Magento 1 configuration in the file. The configuration can be found at the bottom of the magento.nginx.conf file. You can enable the configuration by deleting the hashtags (#) from the lines that start with 'location', the configuration will look like this:

################################
# Magento 1 configuration
################################
location ^~ /app/ { return 404; }
location ^~ /includes/ { return 404; }
location ^~ /lib/ { return 404; }
location ^~ /media/downloadable/ { return 404; }
location ^~ /pkginfo/ { return 404; }
location ^~ /report/config.xml { return 404; }
location ^~ /var/ { return 404; }
location ^~ /shell/ { return 404; }
location ^~ /cron.php { return 404; }
location ^~ /rss/ { return 404; }

Save the file and reload the Nginx configuration Save the file right after the adjustment. Reload the Nginx configuration with the command: nginx-reload. The following output will be displayed:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Nginx configuration reload successful

The configurations are enabled and the sensitive locations are shielded from the outside.