You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Dragon <dr...@crimson-dragon.com> on 2007/05/22 21:29:05 UTC
[users@httpd] A reverse proxy question
Before asking my question, I need to explain a little about what I am
trying to do.
I have a reverse proxy set up in Apache 2.0.54 using the instructions
detailed in http://www.apachetutor.org/admin/reverseproxies
It works great for the most part but I have one little thing that
causes me some problems in the Rails application I am proxying. The
problem revolves around some internal redirects the application does
that I am currently "fixing" by hard coding the URL as seen from the
outside world into the application where it does these page
redirects. This is not an ideal solution as it breaks things if I
access the application directly instead of through the proxy.
What I want to be able to do is to inform the application that it is
being accessed through the proxy so it can programmatically determine
the correct redirect URL regardless of how it is being accessed.
Essentially what I want to do is somehow pass the actual request URL
through the proxy to the application so it can dynamically fix the
URL to access the correct page.
So my question is this, is there some (easy?) way through either HTTP
headers or some other mechanism that I can inform the application
that it is being accessed through the proxy?
Dragon
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Venimus, Saltavimus, Bibimus (et naribus canium capti sumus)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---------------------------------------------------------------------
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] A reverse proxy question
Posted by Dragon <dr...@crimson-dragon.com>.
Joshua Slive wrote:
>First question: Why aren't you just letting ProxyPassReverse do its
>job? It should be able to handle rewriting of redirects.
That is the crux of the problem. I am not sure if I can explain this
correctly but it appears that the application is doing something
internally that hijacks the normal HTTP redirect flow so the normal
mechanism works fine for almost everything except a few cases. I
really don't know how to capture the actual headers so I can tell you
exactly what is happening here when it does not work.
On the application side, I can get to the method calls that force the
redirects and add the correct path to them. I have not gotten into
the internals of these methods and don't want to go rewriting
libraries to "fix" the problem. This is a special case which has come
about because I can't get Ruby and Rails to serve properly via Apache
directly on a Plesk based machine. (I posted about that a couple of
months ago and never found a resolution to the premature end of
script headers problems I was seeing). I ended up having to run an
instance of lighttpd on another port and then proxy to it to make the
application work at all.
So because I can't get the application running directly under Apache,
I am forced to kludge together something that works but has a few
quirks that need a bit of help to get around.
>Anyway, if you want the origin server to know that stuff went through
>the proxy, there are lots of clues in the request headers by default.
>Take a look at X-Forwarded-For, etc.
>
>Or you can always add your own header:
>RequestHeader Set X-Went-Through-Proxy Yes
OK, will do. Now I have to figure out how to retrieve those headers
in a Ruby application.
Dragon
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Venimus, Saltavimus, Bibimus (et naribus canium capti sumus)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---------------------------------------------------------------------
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] A reverse proxy question
Posted by Joshua Slive <jo...@slive.ca>.
On 5/22/07, Dragon <dr...@crimson-dragon.com> wrote:
> Before asking my question, I need to explain a little about what I am
> trying to do.
>
> I have a reverse proxy set up in Apache 2.0.54 using the instructions
> detailed in http://www.apachetutor.org/admin/reverseproxies
>
> It works great for the most part but I have one little thing that
> causes me some problems in the Rails application I am proxying. The
> problem revolves around some internal redirects the application does
> that I am currently "fixing" by hard coding the URL as seen from the
> outside world into the application where it does these page
> redirects. This is not an ideal solution as it breaks things if I
> access the application directly instead of through the proxy.
>
> What I want to be able to do is to inform the application that it is
> being accessed through the proxy so it can programmatically determine
> the correct redirect URL regardless of how it is being accessed.
> Essentially what I want to do is somehow pass the actual request URL
> through the proxy to the application so it can dynamically fix the
> URL to access the correct page.
>
> So my question is this, is there some (easy?) way through either HTTP
> headers or some other mechanism that I can inform the application
> that it is being accessed through the proxy?
First question: Why aren't you just letting ProxyPassReverse do its
job? It should be able to handle rewriting of redirects.
Anyway, if you want the origin server to know that stuff went through
the proxy, there are lots of clues in the request headers by default.
Take a look at X-Forwarded-For, etc.
Or you can always add your own header:
RequestHeader Set X-Went-Through-Proxy Yes
Joshua.
---------------------------------------------------------------------
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