Page tree
Skip to end of metadata
Go to start of metadata

Global configuration

 

The default config file is “/etc/nginx/nginx.conf” which achieves the main task of including more config files in “/etc/nginx/conf.d/”. This example has a few other common sense additions and serves as a handy reference.

 Expand source

Individual sites

 

For each site with it’s own domain (in the examples will be called DOMAIN) create a file “/etc/nginx/conf.d/DOMAIN.conf” and copy the following into it.

 Expand source
  • Check carefully for all instances of DOMAIN and replace with your site’s domain.
  • Check all path names are appropriate for your server, especially the “root” directive on line #11.
  • A file is included, “/etc/nginx/fastcgi_params”. It is installed by many distros automatically and removes many headaches, if your server doesn’t have it get a copy from somewhere.
  • The “MAGE_RUN_CODE” and “MAGE_RUN_TYPE” are for multi-store installations, each DOMAIN that represents a store should have that store code instead of “default” (line #53).
  • A password is made available for the “/var/export/” directory. To set up the password for a given USERNAME enter the following command in a terminal.
    htpasswd -c /etc/nginx/htpasswd USERNAME

 

Icon

Test the configuration after every change, instead of restarting the server you usually only need to do;

service nginx reload

SSL Certificates

 

You will need to check the version on your server, through a terminal type this

nginx -v

and make a note of it.

Versions earlier than 0.7.14

For each DOMAIN find this on line #8:

listen 80 default;

and replace with this:

listen 443;
ssl on;
ssl_certificate     /etc/nginx/conf.d/DOMAIN.crt;
ssl_certificate_key /etc/nginx/conf.d/DOMAIN.key;

Place the “DOMAIN.crt” and “DOMAIN.key” files issued by the certificate authority in “/etc/nginx/conf.d/”.

Versions 0.7.14 and newer

At around line #9 insert the following:

listen 443 default ssl;
ssl_certificate     /etc/nginx/conf.d/DOMAIN.crt;
ssl_certificate_key /etc/nginx/conf.d/DOMAIN.key;

Place the “DOMAIN.crt” and “DOMAIN.key” files issued by the certificate authority in “/etc/nginx/conf.d/”.

Fooman Speedster

 

If you plan on using Fooman Speedster you’ll need to add the following to the server block.

    rewrite ^/minify/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;
    rewrite ^/skin/m/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;

    location /lib/minify/ {
        allow all;
    }

 

 

  • No labels