Why is proxy_set_header Host $host; no longer working in nginx 1.8.0?

匿名 (未验证) 提交于 2019-12-03 08:44:33

问题:

I used proxy_set_header Host $host; to set the host header to the original request host. In nginx 1.4.1 this was working fine. Now after upgrading to 1.8.0, I'm getting the local IP instead of the host passed by the browser.

Why did this happen and how do I fix it?

回答1:

tl;dr; I'm not sure when it changed, but newer versions of nginx -- instead of ssl_protocols ...; -- your conf should be:

proxy_ssl_server_name on; proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

Source: https://stackoverflow.com/a/25330027

===

If you were like me, you were misreading the log files and seeing host=example.com. Instead of this being the host sent to the origin, this seems to mean host-as-defined-in-nginx-conf i.e. virtual host.

(Turning on error_log debug; showed that the host header was being correctly set.)

The log file should also contain an error like "sslv3 alert handshake failure".



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!