configuring mod_proxy_html properly?

Posted by tobinjim on Server Fault See other posts from Server Fault or by tobinjim
Published on 2012-08-27T02:38:57Z Indexed on 2012/08/29 15:40 UTC
Read the original article Hit count: 261

Filed under:

I have an apache2 web server that handles reverse proxy for Rails3 app running on another machine.

The setup works except URLs generated within the webapp aren't getting rewritten by my configuration for mod_proxy_html.

The ["Reverse Proxy Scenario"][1] is exactly what I'm trying to do, so I've followed the tutorial as completely as I know how.

I've applied or tried answers supplied here on stackoverflow, to no effect.

According to the "Reverse Proxy Scenario" you want a number of modules loaded. All those instructions are in my httpd.conf file and when I examine the output from

apactectl -t -D DUMP_MODULES

all the expected modules show in amongst the listing.

My external web server doing the reverse proxy is at www.ourdomain.org and the Rails app is internally available at apphost.local (the server is Mac OS X Server 10.6, the rails app server is Mac OS X 10.6).

What's working right now is access to the webapp via the reverse proxy as:

http://www.ourdomain.org/apphost/railsappname/controllername/action 

But none of the javascript files, css files or other assets get loaded, and links internal to the web app come out missing the apphost portion of the URL, as if my rewrite rule is configured incorrectly (so of course I've focused on that and can't seem to get anything to be added or deleted in the process of passing the html in from the apphost and out through the Apache server).

For instance, hovering over an action link in the html returned by the web app you'll get:

http://www.ourdomain.org/railsappname/controllername/action

Here's what my Apache directives look like:

LoadModule proxy_html_module /usr/libexec/apache2/mod_proxy_html.so
LoadModule xml2enc_module /usr/libexec/apache2/mod_xml2enc.so
    ProxyHTMLLogVerbose On
    LogLevel Debug
    ProxyPass /apphost/  http://apphost.local/
    <Location /apphost/>
            SetOutputFilter INFLATE;proxy-html;DEFLATE
            ProxyPassReverse /
            ProxyHTMLExtended On
            ProxyHTMLURLMap railsappname/ apphost/railsappname/
            RequestHeader unset Accept-Encoding
    </Location>

After every change I make to httpd.conf I religiously check apachectl -t just to be sane.

I'm definitely not an Apache expert, but all the directives that follow mine seem to not overrule what I'm doing here. But then nothing that I try seems to alter the URLs I see in my browser after hitting the Apache server with a request for my web app.

Even if you can't tell what I've done incorrectly, I'd welcome ideas on how to get Apache to help see what it's working on and doing to the html coming from my web app. That's what I understood the ProxyHTMLLogVerbose On and LogLevel Debug to be setting up, but I'm not seeing anything in the log files.

© Server Fault or respective owner

Related posts about apache2