Forum Moderators: phranque

Message Too Old, No Replies

Reverse Proxy Problem

Cannot redirect public http dns name to public https

         

gaab

10:54 pm on Aug 27, 2009 (gmt 0)

10+ Year Member



Hi everyone!

I have been working on setting up a reverse proxy with apache22.

The scenario:

[public.com...] needs to be redirected to [public.com...] which in turn is directed to [internal.local...]

I have tried proxypass/proxypassreverse and rewriterule.

The backend server is IIS.

Any help would be appreciated.

I am using the httpd-vhosts.conf file as well.

gaab

11:19 pm on Aug 27, 2009 (gmt 0)

10+ Year Member



this is as close as I am able to get so far. It always brings me to the "default" IIS webpage and never the site I am looking for but if I type www.internal.local the website comes up. odd.

ProxyRequests Off
<VirtualHost *:80>
ServerName www.public.com
ServerAlias public.com
ProxyPreserveHost On
RewriteEngine on
RewriteRule ^/(.*)$ [public.com...] [L,R]
</VirtualHost>

<VirtualHost *:443>
ServerName www.public.com:443
SSLEngine on
SSLProxyEngine On
RequestHeader set Front-End-Https "On"
ProxyPreserveHost On
RewriteEngine on
CacheDisable *
SetEnvIf User-Agent ".*MSIE.*" value BrowserMSIE
Header unset WWW-Authenticate
Header add WWW-Authenticate "Basic realm=www.public.com"

RewriteRule ^/ [internal.local...] [P]

SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile /usr/local/etc/apache22/extra/SSL/www.public.com.crt
SSLCertificateKeyFile /usr/local/etc/apache22/extra/SSL/myserver.key

SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
</VirtualHost>

jdMorgan

1:12 am on Aug 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not a reverse-proxy expert, but the target address of the proxy rewrite should have a trailing slash on it.

And generally, most people refer to their back-end server using its local IP address instead of a domain name (as long as the back-end *is* on the local network). So, we usually see rules like

 RewriteRule ^/(.*)$ http://192.168.0.3/$1 [P] 

Jim

gaab

12:30 pm on Aug 28, 2009 (gmt 0)

10+ Year Member



Jim,

Thanks for your help. I have tried the following:

RewriteRule ^/(.*)$ [192.168.0.3...] [P] and it still went to the default website.

So then I tried:

RewriteRule ^/(.*)$ [192.168.0.3...] [P] and it loads the page, but it adds an extra /sdc/ to the menu links and looks like /sdc/sdc/page.aspx. Heh.

I have the website setup as both a virtual directory 192.168.0.3/sdc and as website www.internal.local mapped to the same directory and have tried both ways. I should also mention it is not the default website on the IIS server as there are a few websites hosted from this server internally. We also have third party software that can only install in the default website of IIS. Frustrating...

Gerry.

jdMorgan

1:48 pm on Aug 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK, so the back-end needs a hostname in the HTTP Host header sent by the front-end in order to select the correct virtual host on the back-end, so you can't use its IP address.

Did you try the other suggestion -- adding a trailing slash to the domain name?


RewriteRule ^/(.*)$ http://www.internal.loc[b]al/[/b]$1 [P]

This point may be a little confused because I've also added a back-reference to the originally-requested URL-path, so that you'll be able to access all requested resources in the back-end server.

Again, this may not help but even it it doesn't, at least you can cross it off the list of possible problems... :)

Jim

gaab

3:34 pm on Aug 28, 2009 (gmt 0)

10+ Year Member



Jim,

Sorry yes I had also tried:

RewriteRule ^/(.*)$ [internal.local...] [P]

and just for kicks

RewriteRule ^/(.*)$ [internal.local...] [P]

Gerry

jdMorgan

3:59 pm on Aug 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Looking at your code, it seems that ProxyPreserveHost may be a problem. Check the Apache mod_proxy documentation, and see if this is so.

Jim

gaab

5:02 pm on Aug 28, 2009 (gmt 0)

10+ Year Member



Jim,

Thanks, that was exactly the problem! Much appreciated.

Gerry.