# HTTP\_X\_FORWARDED\_HOST breaks Apache proxying

**URL:** <https://www.ruby-forum.com/t/http-x-forwarded-host-breaks-apache-proxying/105756>\
**Category:** Radiant CMS\
**Created:** [June 2, 2007, 5:57am UTC](https://www.ruby-forum.com/t/http-x-forwarded-host-breaks-apache-proxying/105756 "2007-06-02T05:57:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Earl\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/3be4f8/32.png) [@Earl\_C](https://www.ruby-forum.com/u/Earl_C)\
**Post date:** [June 2, 2007, 5:57am UTC](https://www.ruby-forum.com/t/http-x-forwarded-host-breaks-apache-proxying/105756/1 "2007-06-02T05:57:49Z")

</div>

I’m struggling trying to get radiant-0.6.1 installed in a subdirectory.  
My current approach is to use an Apache proxy.

I note there are threads starting:

[http://lists.radiantcms.org/pipermail/radiant/2006-September/002022.html](http://lists.radiantcms.org/pipermail/radiant/2006-September/002022.html)  
[http://lists.radiantcms.org/pipermail/radiant/2006-September/001929.html](http://lists.radiantcms.org/pipermail/radiant/2006-September/001929.html)  
[http://lists.radiantcms.org/pipermail/radiant/2006-November/002405.html](http://lists.radiantcms.org/pipermail/radiant/2006-November/002405.html)

which indicate some other ways this might be done.

For the moment I’m trying the approach suggested in:

[http://lists.radiantcms.org/pipermail/radiant/2007-January/002932.html](http://lists.radiantcms.org/pipermail/radiant/2007-January/002932.html)

which is fairly clean — but I’ve found doesn’t quiet work when  
browsing to /admin. I start radiant via either mongrel or webrick, and  
have it listen on 127.0.0.1:3000.

The problem is that when Apache forwards the request using proxypass, it  
includes the following in the HTML:

* * *

## HTTP\_X\_FORWARDED\_HOST: foo HTTP\_USER\_AGENT: Wget/1.10.2 (Red Hat modified) SCRIPT\_NAME: / SERVER\_PROTOCOL: HTTP/1.1 HTTP\_HOST: 127.0.0.1:3000

This triggers code in  
/radiant-0.6.1/vendor/rails/actionpack/lib/action\_controller/cgi\_process.rb  
to  
prefer the host named in HTTP\_X\_FORWARDED\_HOST

So if I go [http://localhost/radiant/admin](http://localhost/radiant/admin), I get a 302 redirect that  
reads:

HTTP/1.1 302 Moved Temporarily  
Date: Thu, 31 May 2007 20:13:11 GMT  
Server: Mongrel 1.0.1  
Status: 302 Found  
Location: [http://foo/admin/pages](http://foo/admin/pages)

Where the new location has used HTTP\_X\_FORWARDED\_HOST instead of  
HTTP\_HOST.

I can’t quite figure out what the real problem is.

o Is Apache wrong in including HTTP\_X\_FORWARDED\_HOST ?  
I think that’s pretty standard fare, and I can’t see a reason for  
Apache not  
to include that.

o Should radiant ignore HTTP\_X\_FORWARDED\_HOST ?  
Given John L.'s comment in  
[http://lists.radiantcms.org/pipermail/radiant/2006-September/002024.html](http://lists.radiantcms.org/pipermail/radiant/2006-September/002024.html)  
I suspect this might be the right course of action.

o Is the code in action\_controller/cgi\_process.rb wrong in all cases?  
I’m wondering if using HTTP\_X\_FORWARDED\_HOST can ever be the  
right course of action for CGI scripts?
