Welcome! Log In Create A New Profile

Advanced

nginx reverse proxy with 2 upstream servers

Posted by cds 
cds
nginx reverse proxy with 2 upstream servers
March 09, 2015 12:26PM
Hi,

I have 3 subdomains redirected via DNS to a public ipaddress, which is NAT'ed 1:1 to a ubuntu 14.0.4 vm on our private network.
This ubuntu VM has nginx installed in a reverse proxy configuration, which has to push (based on names) the requests to another nginx http server for the moment.

Domains are:

a.mydomain.com
b.mydomain.com
c.mydomain.com

I tried different approaches, but whatever I try the rev. proxy pushes all requests to first entry in the default file (which follows), instead of sending to proper upstream http server:

server {
listen 80;
server_name a.mydomain.com;

location / {
proxy_pass http://10.0.14.10:7070/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}
}

server {
listen 80;
server_name b.mydomain.com c.mydomain.com;

location / {
proxy_pass http://10.0.14.10:80/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}
}



Now all goes to http://10.0.14.10:7070/ no matter what is passed (a.mydomain.com, b.mydomain.com or c.mydomain.com) , if I put http://10.0.14.10:80/; as first entry all will go to that.


Please tell me what is wrong with this simple configuration


Thanks
Regards
C.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 289
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready