如何在不使用 URL 重定向的情况下将向 Apache 服务器发出的请求传输到 IIS 服务器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/959016/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HOWTO transfer a request made to an Apache server to an IIS server without using a URL redirect?
提问by t3.
My Apache 2.2.9 runs on Debian Lenny 5.0.1 with 2 network interfaces, one interface has a public IP and hostname, the other is not configured. This machine caters to services that run on the LAMP stack.
我的 Apache 2.2.9 在 Debian Lenny 5.0.1 上运行,有 2 个网络接口,一个接口有公共 IP 和主机名,另一个没有配置。这台机器迎合在 LAMP 堆栈上运行的服务。
There is a Windows Server 2008 SP2 machine running IIS 7 that serves our ASP.net needs. The box can be configured to be either on a local or a public IP and has 2 network interfaces as well.
有一台运行 IIS 7 的 Windows Server 2008 SP2 机器可以满足我们的 ASP.net 需求。该盒子可以配置为位于本地或公共 IP 上,并且还具有 2 个网络接口。
Both the servers serve over SSL and Apache is public facing.
两个服务器都通过 SSL 提供服务,而 Apache 面向公众。
Is there a way when a request such as https://foo.com/contentfromiis/is made the browser can serve contents from the IIS server without using a redirect and transferring to https://bar.com/iwastransferedhere/. In other words the user must not /experience/ any switch happening. Thanks!
有没有办法在发出诸如https://foo.com/contentfromiis/ 之类的请求时,浏览器可以在不使用重定向并传输到https://bar.com/iwastransferedhere/ 的情况下提供来自 IIS 服务器的内容。换句话说,用户不得/体验/任何切换发生。谢谢!
回答by Laurence Gonsalves
If I understand your situation correctly, I believe you may be able to use mod_proxyto do what you want. Basically, Apache would act as a "reverse proxy" for the requests that you actually want to serve from IIS. Note that a reverse proxy isn't like a normal HTTP proxy. From the mod_proxydocs:
如果我正确理解您的情况,我相信您可以使用mod_proxy它来做您想做的事。基本上,Apache 将充当您实际想要从 IIS 提供服务的请求的“反向代理”。请注意,反向代理与普通的 HTTP 代理不同。从mod_proxy文档:
A reverse proxy ... appears to the client just like an ordinary web server. No special configuration on the client is necessary. The client makes ordinary requests for content in the name-space of the reverse proxy. The reverse proxy then decides where to send those requests, and returns the content as if it was itself the origin.
反向代理...在客户端看来就像一个普通的 Web 服务器。不需要在客户端上进行特殊配置。客户端对反向代理的命名空间中的内容进行普通请求。然后反向代理决定将这些请求发送到哪里,并返回内容,就好像它本身就是源一样。
回答by Stu Thompson
Yes, what Laurence Gonsalves says. Here is a simple as simple can be configuration file that I've taken from a caching reverse proxy server of mine. You should be able to work in some URL matching but I've not done that myself.
是的,劳伦斯·贡萨尔维斯 (Laurence Gonsalves) 就是这么说的。这是我从我的缓存反向代理服务器中获取的一个简单的配置文件。您应该能够处理一些 URL 匹配,但我自己没有这样做。
# httpd *reverse proxy caching server* config file for apache httpd 2.2
ServerRoot "C:/Program Files/Apache Group/Apache2"
#must exist, no reason to have anythign in it
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs"
Listen 127.0.0.1:80
Listen 192.168.1.33:80
ServerAdmin [email protected]
ServerName proxy.server.com
LoadModule auth_module modules/mod_auth.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
### PROXY CONFIGURATION ###
ProxyRequests Off
ProxyVia On
### VH ###
<VirtualHost 192.168.1.33>
ProxyPass / http://192.168.1.34:80/
ProxyPassReverse / http://192.168.1.34:80/
LogLevel info
</VirtualHost>
### LOGGING CONFIGURATION ###
# error log will not catch proxied content
ErrorLog logs/error.log
LogLevel info
LogFormat "%{Host}i %v %h %l %u %t \"%r\" %>s %b common
CustomLog logs/access.log common
TypesConfig conf/mime.types

