Nginx Reverse Proxy

Using CentOS 6 I installed Nginx with:

yum install nginx

and amended the config file for the default website i.e.

vi /etc/nginx/conf.d/default.conf

With the following content:

upstream backend_st {
server {
include /etc/nginx/default.d/*.conf;
access_log /var/log/nginx/log/  main;
error_log  /var/log/nginx/log/;
root   /usr/share/nginx/html;
index  index.html index.htm;
location / {
proxy_pass  http://backend_st;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_buffering off;
proxy_set_header        host           "";
proxy_set_header        x-real-ip       $remote_addr;
proxy_set_header        x-forwarded-for $proxy_add_x_forwarded_for;

So visiting the web address as configured under the ‘server’ section will proxy the website from

Advice on the web specified using $host or configuring the proxy_set_header:

proxy_set_header        Host            $host;

However, when proxying IIS I found that I needed to actually enter the hostname rather than a variable.

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>