I’m writing this down because it too me an age to figure out a way of doing this. I have a website which Tomcat is happily serving. Areas of the site require a secure connection so I’m using Spring security to require particular URLs to be accessed over HTTPS. It means that when I access http://example.org:8080/webapp/login, it’ll bump me to https://example.org:8443/webapp/login. Note: Tomcat is setup with the SSL connector and a self signed .keystore see (http://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html).
I have two vhosts setup in Apache, one for the http://example.org and one for https://example.org. They are both using mod_proxy to ProxyPass and ProxyPassReverse requests to the appropriate Tomcat URL’s. The problem comes when switching to HTTPS from HTTP and vice versa. Ideally I wanted some sort of ProxyPassReverse declaration in my config for http://example.org what would change HTTP headers (that Spring sets) for https://example.org:8443/webapp into https://example.org. Except ProxyPassReverse doesn’t work like that.
Now, I realise I could simply not use Spring to manage which parts of the site should be accessed over HTTPS and which should not…and just setup Apache to redirect as appropriate. I don’t want to do that though, because that makes the task of adding these restrictions a deploy time task, rather than a development time task. I don’t want to risk someone forgetting to add new restrictions when deploying the webapp and I’d much rather the developer added these restrictions when they were working on the task and really thinking about where and when they are needed.
So, how do I solve the problem so that the app can manage its secure-ness and I can setup Apache once and forget about it? The answer is to ProxyPassReverse onto a “special” URL, which when accessed will redirect to the HTTPS (or HTTP) site. For example, if the HTTP site needed to redirect to the HTTPS site, I’d add rules like so to perform the redirect:
# Proxy a request (from the server) to switch to https onto a special URL "/2https/"
ProxyPassReverse /2https/ https://example.org:8443/webapp/
# When a client requests a URL prefixed with "/2https" map it onto the secure site
RewriteRule ^/2https/(.*)$ https://example.org/$1 [R,L]
…and you’d add something similar to the secure site Apache config. As long as I don’t mount any pages at /2http or /2https I should be ok. Note a couple of things:
- You’ll need “SSLProxyEngine on” and “RewriteEngine on” and obviously the appropriate Apache modules loaded for these commands.
- Because of the redirect between HTTP <-> HTTPS you won’t be able to POST data between them directly (I’m not sure why you’d NEED to though)
- Obviously you’ll need to setup Apache with an SSL certificate…but that is a different story
I should say a special thanks to this random site – from whence the idea actually came from. If anyone has any better ideas on how to do it I’d love to hear them. Please comment below.
VisionGuides – Inspiring ideas presented through a polished and well-structured layout.
transition tools page – Practical guidance presented in an easy-to-understand and approachable way.
Progressive Mind – Well-structured layout makes concepts digestible.
energynear help – Accessible layout, information on energy topics is straightforward.
ExecuteVision – Direct, inspiring advice in a layout that’s simple and modern.
NextFocus – Clear navigation and concise information enhance the visitor’s experience.
Action Hub – Organized content ensures readers can grasp ideas without confusion.
clear action framework – Nicely done, the tone is helpful and easy to follow.
Momentum Path – Clean design with actionable advice helps users apply concepts immediately.
пылесос дайсон v15 absolute купить pylesos-dn-2.ru .
пылесос дайсон купить в самаре пылесос дайсон купить в самаре .
дайсон пылесос беспроводной купить спб pylesos-dn-kupit-1.ru .
пылесос дайсон v15 купить pylesos-dn-kupit.ru .
progress through action – Clean message that makes momentum feel achievable.
City Saddle Project – Clear structure, site explains activities well and is simple to browse.
Forward Hub – Organized pages make complex ideas simple and actionable.
Remi Info Hub – Simple design, details are easy to find and understand quickly.
wellnesstourbus info portal – Easy-to-browse layout with inspiring material, encourages healthy habits.
купить пылесос дайсон проводной купить пылесос дайсон проводной .
PrecisionSteps – Practical guidance delivered in a clean and accessible layout.
leadership info page – Straightforward and authentic, with messaging that’s easy to follow.
SmartGrowth – Content is arranged to encourage steady progress without confusion.
DirectionHub – Clear and intuitive site design helps users find actionable advice quickly.
ForwardCreative – Professional appearance with well-structured, digestible content.
Idea Hub – Clear structure makes absorbing and applying concepts straightforward.
дайсон фен купить официальный дайсон фен купить официальный .
дайсон фен купить в москве дайсон фен купить в москве .
Forward Signals – Structured pages and practical guidance allow visitors to follow ideas effortlessly.
дайсон пылесос купить в екатеринбурге pylesos-dn-1.ru .
latanya portfolio – Professional layout, pages load smoothly and information is clear.
Clarity Hub – Organized content and intuitive navigation make learning seamless.
move forward with energy – Friendly and motivating phrasing that inspires practical steps.
GAP Reform Effort – Clear and structured, content is easy to understand and visually clean.
progress energizer – Encouraging idea, sustained focus makes steady gains feel natural.
drive forward efficiently – Clear and approachable, showing that consistent traction accelerates results.
pressbros online – Informative and structured, site feels trustworthy and easy to explore.
CreativeWaypoints – Intuitive layout helps users stay engaged.
tadros info hub – Well-laid-out content that communicates goals and priorities clearly.
PowerGuide – Thoughtful organization ensures readers can access insights with ease.
growth pathways – Smart phrasing, proper growth opens pathways for steady improvement.
forward ideas – Insightful point, open ideas help momentum carry initiatives smoothly.
FocusDrive – Easy-to-navigate site with information explained in simple terms.
Clarity Hub – Simple layout with actionable advice ensures ideas can be applied immediately.
Action Driven Success Online – Dynamic layout, reading and applying strategies is straightforward.
steadyadvance – Clear concept, growth progresses smoothly when steps are intentional and thoughtful.
Action Hub – Clear navigation and concise content make learning fast and efficient.
clicksolutionportal – Practical platform, make a click and uncover solutions efficiently for daily challenges.
фен dyson купить оригинал фен dyson купить оригинал .
Insight Flow – Clear organization supports understanding and practical use.
фен купить дайсон фен купить дайсон .