You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Robert Steinmetz <ro...@steinmetznet.com> on 2009/02/04 01:43:16 UTC

[users@httpd] Reverse Proxy URL confuion.

I am setting up a reverse proxy of an application. I have it working 
mostly except I can get the URLs to respond like I want to. it seem it 
should be simple but now I've gotten myself confused.

>       <VirtualHost * >
>
>        ServerName application.mydomain.com
>       
>        ProxyRequests Off
>
>         <Proxy *>
>         Order deny,allow
>         Allow from all
>         </Proxy>
>
>         ProxyPreserveHost On
>         ProxyPass / http://IPaddresshere/
>         ProxyPassReverse /  http://IPaddress/
>
The application root is http://IPaddress/application I'd like the URL 
http://application.mydomain.com to open the application login

The configuration above works if I open 
http://application.mydomain.com/application.

I'd like to eliminate the  /application

If in <VirtualHost>I add

ProxyPass /http://IPaddress/application/

I get the login but subsequently I get

http://application.mydomain.com/application/file.aspx

instead of

http://application.mydomain/file.aspx

However if I manually enter

http://application/mydomain.com/file.aspx

Everything then seems to work.

I don't have access to the application so I can't see what it is doing.
-- 
*Robert Steinmetz, AIA*
Principal
*Steinmetz & Associates*

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Reverse Proxy URL confuion.

Posted by Matt McCutchen <ma...@mattmccutchen.net>.
On Wed, 2009-02-04 at 12:23 -0600, Robert Steinmetz AIA wrote:
> Here is my entire current VirtualHost some of it is probably redundant, 
> like the <Proxy> tags.
> I have tried a lot of variations and so far none of them have affected 
> the error message I get.
> 
> > <VirtualHost *:80 >
> >
> >         ServerAdmin webmaster@localhost
> >         ServerName application.mydomain.com
> >         # DocumentRoot /var/www/application
> >
> >         ProxyRequests Off
> >
> >         <Proxy *>
> >         Order deny,allow
> >         Allow from all
> >         </Proxy>
> >
> >         ProxyPreserveHost On
> >         ProxyPass / http://192.168.1.2/application/
> >         # ProxyPass / http://192.168.1.2/
> >         ProxyPassReverse /  http://192.168.1.2/application/
> >         # ProxyPassReverse / http://192.168.1.2/
> >
> >         SetOutputFilter  proxy-html
> >         ProxyHTMLInterp On
> >         ProxyHTMLExtended On
> >         ProxyHTMLURLMap / /application S
> >
> >
> > </VirtualHost>
> When I access the server at http://application/mydomain/com
> 
> I get the correct login screen which is actually
> 
>     http://application/mydomain.co/default.aspx

My point was that while you can access the login page fine, it contains
an incorrect link that is sending you to the wrong page after you log
in.  The purpose of mod_proxy_html is to adjust this link.

> After logging in I get this error
> 
> >
> >   Server Error in '/application' Application.
> >   ------------------------------------------------------------------------
> >
> >
> >     /The resource cannot be found./
> >
> > * Description: *HTTP 404. The resource you are looking for (or one of 
> > its dependencies) could have been removed, had its name changed, or is 
> > temporarily unavailable.  Please review the following URL and make 
> > sure that it is spelled correctly.
> >
> > * Requested URL: */application/application/file.aspx
> The browser says its at;
> 
>     http://applicaiton.mydomain.com/application/fileaspx
> 
> If I edit the URL in the browser to
> 
>     http://application.mydoamin.com/file.aspx
> 
> everything works fins and the application performs properly.

Two issues:

1. The error you pasted suggests that your ProxyHTMLURLMap rule is not
taking effect at all.  My guess is that you need to include the
configuration file that defines all the places links appear in HTML:

http://apache.webthing.com/svn/apache/filters/proxy_html/proxy_html.conf

2. Your ProxyHTMLURLMap rule is backwards, since you want to *remove*
the /application prefix from the links generated by the back-end (which
is the reverse of the scenario in the HOWTO, as you can see by comparing
your ProxyPass directive to those in the HOWTO).  The rule should be:

ProxyHTMLURLMap / /application

(I don't understand what the capital S was doing at the end of your
rule.)

Once you get the HTML rewriting working, you will need to enable
ProxyPassReverseCookieDomain and ProxyPassReverseCookiePath if your
application uses cookies.

-- 
Matt


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Reverse Proxy URL confuion.

Posted by Robert Steinmetz AIA <ro...@steinmetznet.com>.
Matt McCutchen wrote:
> On Tue, 2009-02-03 at 21:26 -0600, Robert Steinmetz wrote:
>   
>> I think you may be right I've tried to put  a  ProxyHTMLURLMap in the 
>> configuration, it seems like all I need to do is remove one part of the 
>> url, from one file but so far It hasn't had any effect.
>>     
>
> OK... please post the new configuration and, if possible, the HTML of
> the problematic login page so I can see what is happening.
>
> Also, you may wish to read the following HOWTO if you haven't already.
> Note that your case of HTML rewriting is the reverse of the one in the
> HOWTO in that you want to remove an /application prefix, not add it.
>
> http://www.apachetutor.org/admin/reverseproxies
>
>   
Thanks for the link. That was one of the first ones I found.

Here is my entire current VirtualHost some of it is probably redundant, 
like the <Proxy> tags.
I have tried a lot of variations and so far none of them have affected 
the error message I get.

> <VirtualHost *:80 >
>
>         ServerAdmin webmaster@localhost
>         ServerName application.mydomain.com
>         # DocumentRoot /var/www/application
>
>         ProxyRequests Off
>
>         <Proxy *>
>         Order deny,allow
>         Allow from all
>         </Proxy>
>
>         ProxyPreserveHost On
>         ProxyPass / http://192.168.1.2/application/
>         # ProxyPass / http://192.168.1.2/
>         ProxyPassReverse /  http://192.168.1.2/application/
>         # ProxyPassReverse / http://192.168.1.2/
>
>         SetOutputFilter  proxy-html
>         ProxyHTMLInterp On
>         ProxyHTMLExtended On
>         ProxyHTMLURLMap / /application S
>
>
> </VirtualHost>
When I access the server at http://application/mydomain/com

I get the correct login screen which is actually

    http://application/mydomain.co/default.aspx

After logging in I get this error

>
>   Server Error in '/application' Application.
>   ------------------------------------------------------------------------
>
>
>     /The resource cannot be found./
>
> * Description: *HTTP 404. The resource you are looking for (or one of 
> its dependencies) could have been removed, had its name changed, or is 
> temporarily unavailable.  Please review the following URL and make 
> sure that it is spelled correctly.
>
> * Requested URL: */application/application/file.aspx
The browser says its at;

    http://applicaiton.mydomain.com/application/fileaspx

If I edit the URL in the browser to

    http://application.mydoamin.com/file.aspx

everything works fins and the application performs properly.

Did I mention that the reverse proxy is a  Ubuntu box running apache2 
and the application is on a windows server with IIS .NET and Microsoft SQL.
I have looked at the default.aspx file and don't see what it is doing, 
and since it is a proprietary application I don't think I should publish 
it here.

-- 
Robert Steinmetz, AIA
Principal
Steinmetz & Associates


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Reverse Proxy URL confuion.

Posted by Matt McCutchen <ma...@mattmccutchen.net>.
On Tue, 2009-02-03 at 21:26 -0600, Robert Steinmetz wrote:
> I think you may be right I've tried to put  a  ProxyHTMLURLMap in the 
> configuration, it seems like all I need to do is remove one part of the 
> url, from one file but so far It hasn't had any effect.

OK... please post the new configuration and, if possible, the HTML of
the problematic login page so I can see what is happening.

Also, you may wish to read the following HOWTO if you haven't already.
Note that your case of HTML rewriting is the reverse of the one in the
HOWTO in that you want to remove an /application prefix, not add it.

http://www.apachetutor.org/admin/reverseproxies

-- 
Matt


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Reverse Proxy URL confuion.

Posted by Robert Steinmetz <ro...@steinmetznet.com>.
I think you may be right I've tried to put  a  ProxyHTMLURLMap in the 
configuration, it seems like all I need to do is remove one part of the 
url, from one file but so far It hasn't had any effect.

Matt McCutchen wrote:
> On Tue, 2009-02-03 at 18:43 -0600, Robert Steinmetz wrote:
>   
>> I am setting up a reverse proxy of an application. I have it working 
>> mostly except I can get the URLs to respond like I want to. it seem it 
>> should be simple but now I've gotten myself confused.
>>
>>     
>>>       <VirtualHost * >
>>>
>>>        ServerName application.mydomain.com
>>>       
>>>        ProxyRequests Off
>>>
>>>         <Proxy *>
>>>         Order deny,allow
>>>         Allow from all
>>>         </Proxy>
>>>
>>>         ProxyPreserveHost On
>>>         ProxyPass / http://IPaddresshere/
>>>         ProxyPassReverse /  http://IPaddress/
>>>
>>>       
>> The application root is http://IPaddress/application I'd like the URL 
>> http://application.mydomain.com to open the application login
>>
>> The configuration above works if I open 
>> http://application.mydomain.com/application.
>>
>> I'd like to eliminate the  /application
>>
>> If in <VirtualHost>I add
>>
>> ProxyPass /http://IPaddress/application/
>>
>> I get the login but subsequently I get
>>
>> http://application.mydomain.com/application/file.aspx
>>     
>
> It sounds like the application is generating an absolute link that you
> need to rewrite with mod_proxy_html, as mentioned in the
> ProxyPassReverse documentation:
>
> http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassreverse
>
>   


-- 
*Robert Steinmetz, AIA*
Principal
*Steinmetz & Associates*

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Reverse Proxy URL confuion.

Posted by Matt McCutchen <ma...@mattmccutchen.net>.
On Tue, 2009-02-03 at 18:43 -0600, Robert Steinmetz wrote:
> I am setting up a reverse proxy of an application. I have it working 
> mostly except I can get the URLs to respond like I want to. it seem it 
> should be simple but now I've gotten myself confused.
> 
> >       <VirtualHost * >
> >
> >        ServerName application.mydomain.com
> >       
> >        ProxyRequests Off
> >
> >         <Proxy *>
> >         Order deny,allow
> >         Allow from all
> >         </Proxy>
> >
> >         ProxyPreserveHost On
> >         ProxyPass / http://IPaddresshere/
> >         ProxyPassReverse /  http://IPaddress/
> >
> The application root is http://IPaddress/application I'd like the URL 
> http://application.mydomain.com to open the application login
> 
> The configuration above works if I open 
> http://application.mydomain.com/application.
> 
> I'd like to eliminate the  /application
> 
> If in <VirtualHost>I add
> 
> ProxyPass /http://IPaddress/application/
> 
> I get the login but subsequently I get
> 
> http://application.mydomain.com/application/file.aspx

It sounds like the application is generating an absolute link that you
need to rewrite with mod_proxy_html, as mentioned in the
ProxyPassReverse documentation:

http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassreverse

-- 
Matt


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org