2014
11.25

Using NGINX as Reverse Proxy

I guess this is a continuation of my previous post. So yesterday I officially opened up the reverse proxy to public. Here’s the steps I took:

  1. Add the sub-domain name in our nameserver, pointing it out to one of our public IP
  2. Update the Firewall to ensure the public IP is translated to the NGINX IP address
  3. Update NGINX configuration

Everything runs smoothly except step 1. After 24 hours, the DNS correctly propagated to M1, StarHub and the rest of the Internet. But it didn’t propagated to the SingTel’s network. My colleagues which are subscribing to M1 and StarHub able to resolve the new sub-domain. One colleague which is under SingTel couldn’t. I found rather ironic, since our ISP is actually SingTel! 😛

As of the NGINX configuration, open /etc/nginx/sites-enabled/default then add something similar to below

server {
    listen       80;
    #public sub-domain name
    server_name  myNewApp.myCompany.com.sg;

    access_log  /var/log/nginx/default/myNewApp.myCompany.access.log;
    error_log /var/log/nginx/default/myNewApp.myCompany.error.log;

    # proxy to IIS backend server
    location / {
        proxy_pass         http://10.0.10.122:80/;
        proxy_redirect     off;
        #public sub-domain name
        proxy_set_header   Host             myNewApp.myCompany.com.sg;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_max_temp_file_size 0;

        client_max_body_size       10m;
        client_body_buffer_size    128k;

        proxy_connect_timeout      90;
        proxy_send_timeout         90;
        proxy_read_timeout         90;

        proxy_buffer_size          4k;
        proxy_buffers              4 32k;
        proxy_busy_buffers_size    64k;
        proxy_temp_file_write_size 64k;
    } 
}

Yes, as simple as that. If you are interested to learn more about NGINX, you should start by reading Martin’s post.

GD Star Rating
loading...
Using NGINX as Reverse Proxy, 3.0 out of 5 based on 1 rating

Incoming Search Term

Advertise Here

No Comment

Add Your Comment