I am getting wrong response from nginx
Maxim Dounin
mdounin at mdounin.ru
Tue Apr 17 12:17:57 UTC 2012
Hello!
On Tue, Apr 17, 2012 at 02:43:27PM +0300, Pekka.Panula at sofor.fi wrote:
> I am wondering how does nginx returns wrong content, atleast it seems so.
> I am terminating https addresses to nginx thru my firewall, what does nat
> public ips to nginx to ports 901 and 902 in this case, where nginx is
> configured to wait https connections.
>
> So when end user hits eg address: https://a.host.com/, firewall does nat
> and sends it to nginx private ip port 901, and https://b.host.com/ goes to
> nginx private ip port 902.
[...]
> server {
> listen 81.x.y.x:901;
[...]
> server_name a.host.com atest.host.com;
[...]
> location / {
> proxy_cache off;
> proxy_cache_valid 200 302 0;
> proxy_cache_valid 301 0;
> proxy_cache_valid any 0;
> proxy_set_header ClientProtocol HTTPS;
> proxy_set_header Accept-Encoding "";
> proxy_pass http://1.1.1.131;
This will result in a request with "Host: 1.1.1.131" to a backend
server, see http://nginx.org/r/proxy_set_header.
[...]
> server {
> listen 81.x.y.x:902;
[...]
> server_name b.host.com btest.host.com;
[...]
> location / {
> proxy_cache off;
> proxy_cache_valid 200 302 0;
> proxy_cache_valid 301 0;
> proxy_cache_valid any 0;
> proxy_set_header ClientProtocol HTTPS;
> proxy_set_header Accept-Encoding "";
> proxy_pass http://1.1.1.131;
Same here.
[...]
> Now when i do go to address https://b.host.com/, i am getting response
> from a.host.com.
>
> I am pretty if correct Host header goes to 1.1.1.131 server, it should
> return different content, i have tested it manually using curl, eg:
> " curl --verbose --header 'Host: b.host.com' http://1.1.1.131" from nginx
> machine, i will get correct content, but not thru nginx.
> So i am assuming that somehow i am getting wrong content from a.host.com
> or does nginx somehow leave Host header off?
By default nginx uses the name you wrote in a proxy_pass directive
for the Host header. You probably want to use
proxy_set_header Host $host;
or something similar in the locations above.
[...]
Maxim Dounin
More information about the nginx
mailing list