Welcome! Log In Create A New Profile

Advanced

Host header to be set to upstream name

Posted by neco 
Host header to be set to upstream name
October 23, 2016 04:07PM
I have been playing with nginx and I encountered a problem:


upstream backend_hosts {
server server1.example.com
server server2.example.com
}

server {
listen 80;

location / {
proxy_pass http://backend_hosts;
proxy_set_header Host $name_of_current_upstream (eg. if proxy pass is server1.example.com then the host header would be server1.example.com)
}
}
But there is no such variable as $name_of_current_upstream and no way to generate it.

I need my Host to be set to actual name of current upstream server and that's not possible without workarounds

http://serverfault.com/questions/598202/make-nginx-to-pass-hostname-of-the-upstream-when-reverseproxying



Edited 1 time(s). Last edit at 10/23/2016 04:16PM by neco.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 111
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