Reputation: 151
I'm trying to setup a reverse proxy from apache to an IIS 7 server.
I've setup pretty basic proxy rules.
<VirtualHost *:443>
ServerName MY_APPACHE_SERVER_NAME
SSLEngine on
SSLProxyEngine on
SSLCertificateFile /etc/ssl/certs/...
SSLCertificateKeyFile /etc/ssl/private/...
SSLCertificateChainFile /etc/ssl/certs/...
SSLProxyCheckPeerCN on
SSLProxyCheckPeerExpire on
ProxyPreserveHost On
ProxyPass / https://MY_IIS_SERVER_NAME/
ProxyPassReverse / https://MY_IIS_SERVER_NAME/
</VirtualHost>
If I hit the home page through my proxy, I get a 404 error.
On the IIS server side, in the C:\Windows\System32\LogFiles\HTTPERR\httperr.log file I can see the incoming call and the response set to 404
2015-03-27 15:07:36 184.73.82.33 42313 10.79.154.81 443 HTTP/1.1 GET / 404 - NotFound -
2015-03-27 15:07:52 184.73.82.33 42314 10.79.154.81 443 HTTP/1.1 GET / 404 - NotFound -
And on the http response I can see that the response comes from the IIS server Server: Microsoft-HTTPAPI/2.0
HTTP/1.1 404 Not Found
Date: Fri, 27 Mar 2015 15:07:52 GMT
Server: Microsoft-HTTPAPI/2.0
Content-Type: text/html; charset=us-ascii
Content-Length: 315
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
I can't understand why I can't get my home page when hitting the proxy server. Any help would be appreciated.
Thanks.
Upvotes: 3
Views: 11252
Reputation: 151
Found my problem, it was the "ProxyPreserveHost On" line. It should have been set to OFF.
The IIS server was answering only to MY_IIS_SERVER_NAME. Since I was calling MY_APPACHE_SERVER_NAME, that name was forwarded to the IIS server and the server didn't recognize that name. hence the 404 error.
My final apache config looked like this:
<VirtualHost *:443>
ServerName MY_APPACHE_SERVER_NAME
SSLEngine on
SSLProxyEngine on
SSLCertificateFile /etc/ssl/certs/...
SSLCertificateKeyFile /etc/ssl/private/...
SSLCertificateChainFile /etc/ssl/certs/...
ProxyPreserveHost Off
ProxyRequests Off
ProxyPass / https://MY_IIS_SERVER_NAME/
ProxyPassReverse / https://MY_IIS_SERVER_NAME/
</VirtualHost>
Upvotes: 12