Configure Nginx for SSL

You need to have private key and CA signed certificate (to test you may generate your own Self signed certificate) to configure your nginx to serve request over SSL. Add following lines into your nginx.conf file and make required changes to point ssl_certificate to location of your certificate in this configuration it is server.crt (if you copy your .crt and .key file into <nginx home>/conf folder . In that case you can specify only file name other wise you need to specify absolute path of a file). [Read More]

configure nginx to redirect user from HTTP to HTTPS

When you are going to sever all requests over SSL then in some cases you need to only serve requests over SSL. While doing that you may have to disable port 80 so that all the requests will be only served through SSL. But in that case if user hits your url with http, user will see page not found error. Instead you can enable your port 80 and redirect all requests to https url with following configuration. [Read More]

Configure nginx to server multiple domains / subdomains

With nginx it is quite easy to configure multiple domains or subdomains to be served from single server. Refer following configuration for the same.

        server {
            server_name first.pandurangpatil.com;
            root /var/www/first;
        }

        server {
            server_name second.pandurangpatil.com;
            root /var/www/second;
        }

        server {
            server_name someother.com;
            root /var/www/other;
        }

nginx proxypass configuration with X-Forwarded-Host header

I have used and configured apache for proxy pass and proxy pass reverse multiple times with X-Forwarded-Host. I tried configuring same with nginx and it works out to be more customisable and easy one.

        server {
            listen       80;
            server_name  pandurangpatil.com;
            location /myapp {
                proxy_set_header X-Forwarded-Host $host;
                proxy_pass http://localhost:8080/myapp;
            }
            .
            .
            .
        }

Install nginx on OS-X

One need to have gcc installed for that you need to install xcode along with command line tools. To install the same one can refer to this link for xcode 5.0.1. Nginx requires PCRE – Perl Compatible Regular Expressions to build, I used PCRE version 8.33 Install PCRE $ mkdir source $ cd source $ curl -OL ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.33.tar.gz $ tar -zxvf pcre-8.33.tar.gz $ cd pcre-8.33/ $ ./configure $ make $ sudo make install Install nginx [Read More]