如何设置 apache 2 反向代理转发不同的域并伪装成该域名?
How to setup apache 2 reverse proxy to forward different domain and pretend as that domain name?
我正在使用 Debian 和 apache2,我不知道是否可以使用 apache 将代理从一个域反向代理到另一个域,但是后者服务器后面的后端服务器仍然考虑请求 URL 是后者吗?
例如,如果您访问 https://www.example.com/index.html, the request will forward to https://www.example.org/index.html, but in the backend server of www.example.org still think the requesting URL is https://www.example.org/index.html, not https://www.example.com/index.html
我想我需要更改 apache 代理中的 X-Forwarded-Server header,但我不知道如何更改。任何帮助将不胜感激。
您描述的行为是默认行为:
如果example.com
有如下配置:
ProxyPass / http://example.org/
然后我转到http://example.com/
,然后example.org会看到以下请求(检查Host
header):
GET / HTTP/1.1
Host: example.org
[...]
X-Forwarded-For: <client IP address>
X-Forwarded-Host: example.com
使用 ProxyPreserveHost On
,您更改此行为并获得
GET / HTTP/1.1
Host: example.com
[...]
X-Forwarded-For: <client IP address>
X-Forwarded-Host: example.com
除非 example.org
使用 X-Forwarded-Host
header 来决定要提供什么内容,否则你很好。
我正在使用 Debian 和 apache2,我不知道是否可以使用 apache 将代理从一个域反向代理到另一个域,但是后者服务器后面的后端服务器仍然考虑请求 URL 是后者吗?
例如,如果您访问 https://www.example.com/index.html, the request will forward to https://www.example.org/index.html, but in the backend server of www.example.org still think the requesting URL is https://www.example.org/index.html, not https://www.example.com/index.html
我想我需要更改 apache 代理中的 X-Forwarded-Server header,但我不知道如何更改。任何帮助将不胜感激。
您描述的行为是默认行为:
如果example.com
有如下配置:
ProxyPass / http://example.org/
然后我转到http://example.com/
,然后example.org会看到以下请求(检查Host
header):
GET / HTTP/1.1
Host: example.org
[...]
X-Forwarded-For: <client IP address>
X-Forwarded-Host: example.com
使用 ProxyPreserveHost On
,您更改此行为并获得
GET / HTTP/1.1
Host: example.com
[...]
X-Forwarded-For: <client IP address>
X-Forwarded-Host: example.com
除非 example.org
使用 X-Forwarded-Host
header 来决定要提供什么内容,否则你很好。