upstream server does not match virtual host

miky nginx-forum at forum.nginx.org
Wed Mar 16 00:20:25 UTC 2016


Hello,

I have a web server (nginx, iis, apache, whatever) on which I access:
http://1.1.1.1 => displays default page
http://virt1 => displays virtual host 1 (ping virt 1 = 1.1.1.1)
When I access the url virt1 the page of the corresponding virtual host which
is different from when I access the url with the ip adress
NB: if I access http://1.1.1.1/virt1, it's the same page as http://virt1

I use a nginx server in front of it as a reverse proxy and use a virtual
host. When I access http://portal, I want it to display the page as if it
was http://virt1

My configuration starts like this
upstream webservers { server virt1:80; }
server {
   listen 80;
   server_name server_name portal;
   index index.php index.html;
    location @proxy {
            proxy_pass http://webservers;
            include /etc/nginx/proxy_params;
    }

With this configuration it works but not as I wish.
When I access the page http://portal it displays the page as if I accessed
http://1.1.1.1 but I wanted it to display the page that looks like
http://virt1
If I access http://portal/virt1 it displays the correct page.

Conclusion my configuration makes my nginx connect to the right server but
doesn't send a parameter so that I access on the right virtual host.

Do you know how to correct this ?

Thank you

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,265370,265370#msg-265370



More information about the nginx mailing list