Reputation: 118
i have a question regarding proxypass and proxypass reverse.
I want to be able to reach the following on my app (internally)
https://examplehost/appname/Servletname?method-to-call
But i want people who enter the website externally to see the following:
https://examplehost/Servletname?method-to-call
I have the following in my apache2 .conf file
Proxypass
/ http://examplehost/appname/
ProxypassReverse
/ http://examplehost/
However, when i call my own website externally i get the following error message:
Request URL does not match Recipient URL, "/appname/Servletname?" does not match "/Servletname?
This indicates that the external link not only has a matching problem, but it also sees the wrong link in the first place, since it shouldnt be possible for the external source to see "appname".
I also tried doing the following in the .conf file
Proxypass
/ http://examplehost/appname/
ProxypassReverse
/ http://examplehost/appname/
Does anyone know how to hide the appname without removing access to the app in the webapplication?
Thankful for any helpful answers or links.
Upvotes: 1
Views: 957
Reputation: 42959
A simple internal RewriteRule
should allow to rewrite this is a transparent manner. No need for a proxy strategy with its additional request round trip:
RewriteEngine on
RewriteRule ^/?Servletname$ /appname/Servletname [L,QSA,NC]
I don't really understand the error message you cite, but I have very little information. Question is which component gives that error message... server side? client side? servlet side?
When you require the usage of the proxy module (why ever...) then take a look at the P
flag provided by apache's rewrite module. Alternatively using ProxyPass
directives certainly should be possible too, I only don't see any reason for that. Nevertheless I would suggest something like this:
ProxyPass /Servletname https://examplehost/appname/Servletname
ProxyPassReverse /Servletname https://examplehost/appname/Servletname
And a general hint: you should always prefer to place such rules inside the http servers host configuration instead of using .htaccess style files. Those files are notoriously error prone, hard to debug and they really slow down the server. They are only provided as a last option for situations where you do not have control over the host configuration (read: really cheap hosting service providers) or if you have an application that relies on writing its own rewrite rules (which is an obvious security nightmare).
Upvotes: 1