NGINX不正确的基本url

我有apache坐在9000然后nginx反向代理它。 在下面configuration我们

upstream lb_servers { least_conn; server 127.0.0.1:9000; server localhost:9000; } # HTTPS server # server { listen 443 ssl default deferred; server_name domain.name; ssl_session_cache shared:SSL:50m; ssl_session_timeout 5m; ssl_stapling on; ssl_stapling_verify on; root /www/; index index.html index.htm; location / { proxy_http_version 1.1; proxy_pass http://lb_servers; } } 

问题是HTML回来以下

 <head> <base href="http://lb_servers/" /> ... </head> 

如何将域名放入href而不是http://lb_servers/

PS重新问为什么apache,然后nginx,我已经使用docker(Apache内置泊坞窗)已经准备好nginx安全脚本与letsecrypt设置等,我已经迁移了一个传统的应用程序。我不想花太多的时间了。

<base href...>标签是由运行在Apache后面的应用程序生成的。 nginx不会改变上游连接的输出,尽pipe你可以尝试使用sub_filter模块来replace内容。

最好更改上游应用程序,以便生成正确的内容。

可能你应该使用proxy_set_header指令。

 proxy_pass http://lb_servers; proxy_set_header Host $host; 

默认情况下,nginx使用$proxy_hostvariables的值作为Host头。