I would like to force my users to use https to log in. Unfortunately the "redirect" directive does not seem to work in cunjunction with "ProxyPass"
<VirtualHost *:80>
ServerName www.domain.com
# This does not work
Redirect permanent /app/login.jsp https://www.domain.com/app/login.jsp
ProxyPass /app http://localhost:8080/app
ProxyPassReverse /app http://localhost:8080/app
</VirtualHost>
Any idea ? Thanks.
ProxyPass is the main proxy configuration directive. In this case, it specifies that everything under the root URL ( / ) should be mapped to the backend server at the given address.
ProxyPassReverse will intercept those headers, and rewrite them to match the Apache proxy server. ProxyPass will create a reverse proxy. A reverse proxy (or gateway), appears to the client just like an ordinary web server. The client makes ordinary requests for content in the namespace of the reverse proxy.
ProxyPassReverse. The directive ProxyPassReverse lets Apache adjust the URL in the Location header on HTTP redirect responses. For instance this is essential when Apache is used as a reverse proxy to avoid by-passing the reverse proxy because of HTTP redirects on the backend servers which stay behind the reverse proxy.
Found an answer to this question here:
https://serverfault.com/questions/605931/can-you-use-redirect-and-proxypass-at-the-same-time
The following needs to be added before the other proxypass directives:
ProxyPass /app/login.jsp !
I had a more complicated use case and it required the use of ProxyPassMatch
. It went a little something like this:
ProxyPassMatch ^/app(/(index.html)?)?$ !
RedirectMatch ^/app(/(index.html)?)?$ /path/to/login/page.html
ProxyPass /app/* http://remote-server/app
ProxyPassReverse /app/* http://remote-server/app
I had to use ProxyPassMatch
because ProxyPass
otherwise performs prefix-matching. You need to match on the end-of-string, so ProxyPassMatch
with a $
regular expression metacharacter is critical.
Here, RedirectMatch
is used in the same way, because Redirect
also performs prefix-matching as well. The two directives also have a nice symmetry, too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With