简体   繁体   English

如何设置Apache 2反向代理以转发不同的域并假装为该域名?

[英]How to setup apache 2 reverse proxy to forward different domain and pretend as that domain name?

I am using Debian and apache2, I don't know if it is possible to using apache to reverse proxy from one domain to another domain, but the backend server behind the latter server still consider the requesting URL is of the latter? 我正在使用Debian和apache2,我不知道是否可以使用apache将代理从一个域反向转换到另一个域,但是后者服务器背后的后端服务器仍然认为请求URL是后者的?

For example if you visit 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 例如,如果您访问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

I think I need to change the X-Forwarded-Server header in the apache proxying, but I don't know how. 我想我需要在apache代理中更改X-Forwarded-Server标头,但我不知道如何。 Any help would be highly appreciated. 任何帮助将不胜感激。

The behavior you describe is the default behavior: 您描述的行为是默认行为:

If example.com has the following configuration: 如果example.com具有以下配置:

ProxyPass / http://example.org/

And I go to http://example.com/ , then example.org will see the following request (check the Host header): 然后转到http://example.com/ ,然后example.org将看到以下请求(检查Host标头):

GET / HTTP/1.1
Host: example.org
[...]
X-Forwarded-For: <client IP address>
X-Forwarded-Host: example.com

With ProxyPreserveHost On , you change this behavior and get ProxyPreserveHost On ,您可以更改此行为并获得

GET / HTTP/1.1
Host: example.com
[...]
X-Forwarded-For: <client IP address>
X-Forwarded-Host: example.com

Unless example.org uses the X-Forwarded-Host header to decides what content to serve, you're good. 除非example.org使用X-Forwarded-Host标头来决定要提供的内容,否则您很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Apache反向代理如何修复跨域 - How Apache Reverse-Proxy to fix cross-domain 如何将Apache反向代理域URL配置为本地主机上的特定URL - How to configure Apache reverse proxy domain url to specific url on localhost Apache 可以同时设置为正向代理和反向代理吗? - Can Apache be setup as forward proxy and reverse proxy at the same time? 如何使用Apache HTTPD在同一服务器上设置正向代理和反向代理 - How to setup a forward proxy and a reverse proxy on the same server using Apache HTTPD 反向代理不保留原始域名 - Reverse proxy not keeping the original domain name 如何使用正向代理后面的Apache反向代理主机 - How to reverse proxy a host with apache that is behind a forward proxy 如何确定Apache是​​用作正向代理还是反向代理? - How to determine whether Apache is using as Forward Proxy or Reverse Proxy? 如何使用 Apache 正确配置反向代理,以用于跨域 AJAX? - How to correctly configure a reverse proxy with Apache, to be used for cross-domain AJAX? Apache2 SSL设置适用于静态IP,但不适用于域名 - Apache2 SSL setup works with Static IP but not with domain name 如何配置Apache Proxy? 需要将没有域名的请求发送到差异服务器 - How to configure Apache Proxy? Need to send requests without a domain name to a diff server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM