0

I'm trying to set up two Apache ProxyPass rules to direct to different Nexus servers. What I want is:

http://mainserver/nexus -> http://server1:8080/nexus

and

http://mainserver/nexus-pro -> http://server2:8081/nexus

I had it set up to work with our original server, but adding a second rule causes requests for nexus-pro to redirect to the main apache server with /nexus, which then forwards on to the wrong server, thus:

http://mainserver/nexus-pro -> http://mainserver/nexus -> http://server1:8080/nexus

I imagine this is something Nexus is doing itself, but I'm not really in control of that.

Here is my current Apache config, what do I need to change?

ProxyPass /nexus http://server1:8080/nexus
ProxyPassReverse /nexus http://server1:8080/nexus

ProxyPass /nexus-pro http://server2:8081/nexus
ProxyPassReverse /nexus-pro http://server2:8081/nexus

ProxyPreserveHost On
RCross
  • 4,919
  • 4
  • 44
  • 42
  • Try reversing the definitions. Place ProxyPass /nexus-pro before ProxyPass /nexus. Apache should process that one first – David H. Bennett Mar 03 '14 at 17:24
  • This didn't solve the problem - I still get sent to the Nexus server on server1. – RCross Mar 20 '14 at 12:43
  • Try the second answer to test the configuration. I just verified that this works. Make sure you are reloading your httpd configuration. – David H. Bennett Mar 20 '14 at 13:10
  • Hmmm... this times out and then gives a 503. I should have mentioned that my Apache server sits behind a proxy. I'll re-do your example, but proxying internal sites and see what happens. – RCross Mar 20 '14 at 15:25
  • Ok, this works fine. So is the problem that Nexus is redirecting to /nexus at some point, causing the second ProxyPass rule to be applied? – RCross Mar 20 '14 at 15:30
  • Use browser debugger (firebug,chrome,ie dev tools) watch watch the network req/resp to see if there are any redirects that aren't being handled. You may be able to work around the problem with RewriteRule. – David H. Bennett Mar 20 '14 at 15:52
  • Yes, mod_rewrite was going to be my next step, thanks for all your help :-) – RCross Mar 21 '14 at 08:41

2 Answers2

1

Within a given section, Apache httpd configurations are processed in the order in which they appear in the configuration. If you transpose the two definitions, the more explicit /nexus-pro will override the /nexus definition.

ProxyPass /nexus-pro http://server2:8081/nexus
ProxyPassReverse /nexus-pro http://server2:8081/nexus

ProxyPass /nexus http://server1:8080/nexus
ProxyPassReverse /nexus http://server1:8080/nexus

ProxyPreserveHost On

Read http://httpd.apache.org/docs/current/sections.html#merging for more information.

David H. Bennett
  • 1,822
  • 13
  • 16
0

You can try these two lines for testing:

ProxyPass /example-ip http://www.toolsvoid.com/what-is-my-ip-address
ProxyPassReverse /example-ip http://www.toolsvoid.com/what-is-my-ip-address

ProxyPass /example http://www.example.com/
ProxyPassReverse /example http://www.example.com/
David H. Bennett
  • 1,822
  • 13
  • 16