Welcome! Log In Create A New Profile

Advanced

simple reverse web proxy need a little help

December 06, 2017 05:27PM
I'm new to nginx but needed a solution like this. It's very cool but I'm a newbie with a small problem.

I'm using nginx as a simple reverse web proxy. I have 3 domains on 2 servers. I'm using 3 files in sites-enabled called your-vhost1.conf , your-vhost2.conf and so on. The stand alone domain is vhost1. The problem is, one of the domains on the server that has 2 isn't resolving correctly from the outside world. It only resolves correctly when you use just http://domain.com. If you use http://www.domain.com it resolves to the vhost1 domain. I tried shuffling the vhost1,2, & 3 files to different domains but that breaks it.

A bit more info I've got an A record in DNS for WWW for the domain in question. It is hosted on a Windows server with IIS7 and I also have WWW in site bindings. This server was standalone before we added the 3rd domain on the second server. It did resolve correctly before we added the nginx server so I'm fairly certain I just don't have the syntax right. The standalone server is Debian with a Wordpress site. Here's the vhost files:

VHOST1 (Standalone)

server {

server_name domain1.com;

set $upstream 192.168.7.8;

location / {

proxy_pass_header Authorization;
proxy_pass http://domain1.com;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_buffering off;
client_max_body_size 0;
proxy_read_timeout 36000s;
proxy_redirect off;

}
}


VHOST2

server {

server_name domain2.com;

set $upstream 192.168.7.254;

location / {

proxy_pass_header Authorization;
proxy_pass http://www.domain2.com;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_buffering off;
client_max_body_size 0;
proxy_read_timeout 36000s;
proxy_redirect off;

}
}

VHOST3

server {

server_name domain3.com;

set $upstream 192.168.7.254;

location / {

proxy_pass_header Authorization;
proxy_pass http://domain3.com;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_buffering off;
client_max_body_size 0;
proxy_read_timeout 36000s;
proxy_redirect off;

}
}
Subject Author Posted

simple reverse web proxy need a little help

qwazi December 06, 2017 05:27PM

Re: simple reverse web proxy need a little help

pbooth December 06, 2017 05:44PM

Re: simple reverse web proxy need a little help

qwazi December 06, 2017 09:17PM

Re: simple reverse web proxy need a little help

qwazi December 06, 2017 09:29PM

Re: simple reverse web proxy need a little help

Francis Daly December 07, 2017 03:06AM

Re: simple reverse web proxy need a little help

qwazi December 07, 2017 11:42AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 58
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready