簡體   English   中英

如何設置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 ,則請求將轉發到https://www.example.org/index.html ,但仍在www.example.org的后端服務器中認為發出請求的URL是https://www.example.org/index.html ,而不是https://www.example.com/index.html

我想我需要在apache代理中更改X-Forwarded-Server標頭,但我不知道如何。 任何幫助將不勝感激。

您描述的行為是默認行為:

如果example.com具有以下配置:

ProxyPass / http://example.org/

然后轉到http://example.com/ ,然后example.org將看到以下請求(檢查Host標頭):

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標頭來決定要提供的內容,否則您很好。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM