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.
Stepwise Hub – Organized content and simple navigation allow visitors to grasp concepts efficiently.
Mind Flow – Organized and intuitive design supports efficient understanding.
lessthinkingmoreaction – Strong concept, thinking less often leads to better and faster movement.
DailyGrab – Making your regular shopping experiences easier and more fun.
concentrate to advance – Short and approachable, showing focus leads to tangible movement.
DreamEmporium – A friendly shopping experience with well-presented items.
momentum through ideas – Strong message, when ideas are released, momentum grows steadily and reliably.
IntelligenceInAction – Sharp, clear design paired with motivational content that guides readers effectively.
energy unleashed – Smooth, natural language emphasizing the effect of freed energy on forward movement.
signal focused guide – Read this today and the meaning was obvious.
Insight Hub – Well-organized design makes exploring concepts enjoyable and simple.
clear pathways – Thoughtful message, clear pathways help growth move forward effortlessly.
SkillSprint – Encourages fast, focused improvement and daily progress.
energy guidepost – Friendly and practical, proper direction of energy keeps productivity consistent.
Stepwise Hub – Neat pages with actionable guidance allow users to follow concepts smoothly.
InsightShop – Inspires thoughtful shopping habits to improve everyday decisions.
>quickbuydeals – Smooth interface, shopping for bargains feels fast and hassle-free.
купить пылесос дайсон абсолют купить пылесос дайсон абсолют .
пылесос dyson v15 detect absolute пылесос dyson v15 detect absolute .
купить пылесос дайсон 15 pylesos-dn-kupit.ru .
вертикальные пылесосы дайсон купить в москве вертикальные пылесосы дайсон купить в москве .
пылесос дайсон купить в курске pylesos-dn-2.ru .
вертикальный моющий пылесос дайсон купить dn-pylesos-kupit.ru .
clarity through planning – Smooth and encouraging, helping ideas flow logically.
clarity unlocks progress – Strong concept, clarity unlocks momentum and helps tasks move forward smoothly.
clarity sparks progress – Straightforward and motivating, makes it easy to move forward with confidence.
execution navigator – Clear concept, staying focused helps guide tasks smoothly and efficiently.
clarity mover – Motivating idea, each small step moves you closer to clear priorities naturally.
dyson пылесос detect absolute pylesos-dn-kupit-2.ru .
SureCart – Smooth, secure, and dependable online buying experience.
uncovernewpaths – Helpful note, uncovering new paths helps explore options you might not notice otherwise.
bright strategies – Strong idea, bright strategies drive forward initiatives and encourage steady work.
directed energy for growth – Smooth, motivating language linking focus and measurable results.
focused decisions – Encouraging and clear, provides insight that drives confident action forward.
focused clarity – Strong idea, clarity combined with focus opens opportunities quickly.
forward with purpose – Friendly and motivating, highlighting intentional movement toward goals.
FocusedProgress – Helps plan and follow a clear path for achieving success.
quickbuycenter – Helpful approach, purchases are simple and efficient with minimal hassle.
SecureBuy – Confidently browse and shop without stress.
purposeful ideas – Friendly phrasing, directing attention toward ideas ensures actionable outcomes.
harmonious growth – Thoughtful phrasing, when focus and plan align, growth moves cleanly forward.
direction sparks progress – Short, energizing phrasing that makes growth feel achievable.
driving focus – Thoughtful idea, clarity in focus keeps projects advancing consistently.
strategic signals – Gentle, motivating tone, highlighting that intentional signals guide progress smoothly.
пылесос дайсон где купить пылесос дайсон где купить .
velocity unleashed – Friendly and clear, performing actions releases energy that sustains forward movement.
simplifyshopping – Encouraging tip, better paths simplify the process of discovering useful products.
RapidOutlet – A convenient hub for quick, everyday shopping needs.
momentum path – Encouraging insight, steady progress creates a clear path of momentum for ongoing success.
ideas spark action – Simple, effective wording that highlights the natural flow from thought to progress.