0

I have ActiveMQ and Accumulo running which each have their own web console. I'd like to put apache httpd in front of them. I setup mod_proxy and added the following to /etc/httpd/conf.d/proxy.conf

ProxyPass /activemq http://1.2.3.4:8161
ProxyPassReverse /activemq http://1.2.3.4:8161

ProxyPass /accumulo http://5.6.7.8:50095
ProxyPassReverse /accumulo http://5.6.7.8:50095

The problem is the AMQ and Accumulo sites don't work/look as they should because their HTML tries to load images, css, js using urls such as <img src="/images/logo.jpg">

How can I fix things to the js/css, etc load properly?

Sven
  • 98,649
  • 14
  • 180
  • 226
codecraig
  • 387
  • 2
  • 4
  • 8

1 Answers1

2

You have multiple options, none of which are ideal:

  • Maybe you're lucky and only a couple of non-overlapping folders are used in the root of each application and you can simply add multiple ProxyPass directives.

  • Redeploy ActiveMQ and Accumulo so that they're no longer installed in the root but in a subfolder.

  • Use subdomains for each application such as activemq.example.com and accumulo.example.com and direct your site users there.

i.e. something like:

<VirtualHost *:80>
    ServerName activemq.example.com
    ProxyPass / http://1.2.3.4:8161
    ProxyPassReverse / http://1.2.3.4:8161
</VirtualHost>
  • You can actually get apache to to not only proxy requests to your internal applications but also rewrite the response body before it will be transmitted to your site visitors. (Normally a proxy only rewrites HTTP headers/responses). mod_substitute in apache 2.2.

I haven't tested if it stacks well with mod_proxy and might cause significant overhead, but maybe the following works:

<Location /activemq/>
  ProxyPass http://1.2.3.4:8161
  ProxyPassReverse http://1.2.3.4:8161
  AddOutputFilterByType SUBSTITUTE text/html
  Substitute "s|/images/|/activemq/images/|i" 
</Location>
HBruijn
  • 77,029
  • 24
  • 135
  • 201
  • Thanks for the response. The proxy server is accessed via IP so subdomains won't be an option (I don't have control over the DNS). I will take a look at option 1 (but I'm guessing I might not be that lucky, especially as we add more apps). The last option might have to suffice. – codecraig Aug 07 '14 at 11:35
  • Substitute is doing the trick. Looks like there is a mod_proxy_html but only for httpd 2.4+, I'm on 2.2.x. Thanks. – codecraig Aug 07 '14 at 17:39