Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retain original request URL on mod_proxy redirect

Tags:

I am running a WebApplication on a Servlet Container (port 8080) in an environment that can be accessed from the internet (external) and from company inside (intenal), e.g.

http://external.foo.bar/MyApplication http://internal.foo.bar/MyApplication 

The incomming (external/internal) requests are redirected to the servlet container using an apache http server with mod_proxy. The configuration looks like this:

ProxyPass /MyApplication http://localhost:8080/MyApplication retry=1 acquire=3000 timeout=600 Keepalive=On ProxyPassReverse /MyApplication http://localhost:8080/MyApplication 

I am now facing the problem that some MyApplication responses depend on the original request URL. Concrete: a WSDL document will be provided with a element that has a schemaLocation="<RequestUrl>?xsd=MyApplication.xsd" element.

With my current configuration it always looks like

<xs:import namespace="..." schemaLocation="http://localhost:8080/MyApplication?xsd=MyApplication.xsd"/> 

but it should be

External Request: <xs:import namespace="..." schemaLocation="http://external.foo.bar/MyApplication?xsd=MyApplication.xsd"/> Internal Request: <xs:import namespace="..." schemaLocation="http://internal.foo.bar/MyApplication?xsd=MyApplication.xsd"/> 

I suppose this is a common requirement. But as I am no expert in configuration of the apache http server and its modules I would be glad if someone could give some (detailed) help.

Thanks in advance!

like image 962
FrVaBe Avatar asked May 20 '11 10:05

FrVaBe


People also ask

What is ProxyPass reverse?

Simple reverse proxyingThe ProxyPass directive specifies the mapping of incoming requests to the backend server (or a cluster of servers known as a Balancer group). The simplest example proxies all requests ( "/" ) to a single backend: ProxyPass "/" "http://www.example.com/"

What is proxy preserve host?

The ProxyPreserveHost directive is used to instruct Apache mod_proxy, when acting as a reverse proxy, to preserve and retain the original Host: header from the client browser when constructing the proxied request to send to the target server.

What is Mod_proxy_ajp?

Extension. Module: mod_proxy. This directive is only useful for Apache httpd proxy servers within intranets. The NoProxy directive specifies a list of subnets, IP addresses, hosts and/or domains, separated by spaces.


1 Answers

If you're running Apache >= 2.0.31 then you might try to set the ProxyPreserveHost directive as described here.

This should pass the original Host header trough mod_proxy into your application, and normally the request URL will be rebuild there (in your Servlet container) using the Host header, so the schema location should be build using the host and path infos from "before" the proxy.

(Posted here too for the sake of completeness)

like image 55
jCoder Avatar answered Oct 10 '22 16:10

jCoder