simple reverse web proxy need a little help
qwazi
nginx-forum at forum.nginx.org
Wed Dec 6 22:27:01 UTC 2017
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;
}
}
Posted at Nginx Forum: https://forum.nginx.org/read.php?2,277674,277674#msg-277674
More information about the nginx
mailing list