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.
clarity leads forward – Encouraging tone, shows how clear steps make movement predictable and confident.
Adorable Fur Boutique – Friendly experience, site is welcoming and product browsing is straightforward.
progress happens through action – Logical phrasing linking effort to results.
GrowthPath – Structured content makes understanding next steps simple and practical.
steady flow forward – Clear and motivating, emphasizing consistent, guided advancement.
SmartExecution – Logical design and concise ideas help visitors act without confusion.
moes food hub – Easy-to-navigate and vibrant, had me wanting to try everything right away.
clarity push – Practical thought, a clear focus pushes momentum in the right direction.
DirectionDriven – Clean structure makes actionable ideas easy to apply.
harmony in motion – Thoughtful phrasing, proper direction produces harmony and alignment in all actions.
Growth Compass – Layout is intuitive, making complex information simple to follow.
дайсон стайлер для волос с насадками официальный сайт цена купит… дайсон стайлер для волос с насадками официальный сайт цена купит… .
пылесос dyson v15s detect pylesos-dsn.ru .
Step Forward – Well-laid-out pages and practical tips make the site easy to navigate and understand.
plannedadvancement – Helpful concept, growth is mapped with precision and structured for sustainable progress.
SmartDecision – Guides you to smarter choices without the usual browsing stress.
PathwayDiscoveries – Well-laid-out content allows ideas to be absorbed quickly and easily.
купить пылесос дайсон абсолют купить пылесос дайсон абсолют .
Simple Steps – Presents concepts clearly with a neat, easy-to-follow design.
ростов купить пылесос дайсон pylesos-dn-kupit-1.ru .
energy pipeline – Smart concept, focused direction supplies energy to tasks seamlessly.
дайсон пылесос купить в москве оригинал pylesos-dn-kupit.ru .
W4 Official Campaign – Clear and professional, content is easy to navigate and well organized.
KnowledgeAdvance – Provides a clear path for skill growth and learning success.
growth through understanding – Smooth, approachable wording that highlights careful planning.
дайсон пылесос оригинал dn-pylesos-kupit.ru .
вертикальный моющий пылесос дайсон купить pylesos-dsn-1.ru .
BusinessGrowthIdeas – Clean presentation with ideas that are easy to read and apply.
FocusedVision – Concise and well-organized content provides clarity for setting realistic goals.
drive forward – Encouraging phrasing, showing that clarity of direction inspires tangible motion.
uncommitted NJ official portal – Insightful and to the point, site presents perspectives clearly.
clarity boosts leverage – Insightful point, clarity provides leverage that makes work and planning more effective.
FuturePathways – Organized pages make understanding and applying ideas effortless.
Innovation Path – Logical flow and professional design make ideas easy to grasp.
пылесос дайсон купить во владимире pylesos-dn-kupit-2.ru .
focused direction – Motivating phrasing, focusing direction amplifies motion naturally and effectively.
Momentum Flow – Clear layout and structured content allow readers to take actionable steps quickly.
RapidCart – Navigate and shop easily, making purchasing quick and simple.
flowthroughdesign – Effective concept, growth moves fluidly when guided by thoughtful design practices.
steady momentum – Clear concept, momentum grows naturally when steps are taken consistently.
Insight Compass – Organized content ensures concepts are clear and actionable.
a href=”https://createimpactplanningframework.click/” />ImpactOrganizer – Practical tools combined with a clear layout streamline project planning.
step into your path – Approachable and motivating phrasing for taking deliberate action.
NewAngleHub – Thought-provoking site that supports learning through exploration.
OutcomeAchiever – Clean interface paired with practical content drives progress effectively.
fuel your forward motion – Encouraging phrasing, illustrating that clear direction amplifies energy.
directioncreatesvelocity boost – Smart concept, clear direction naturally creates velocity in any workflow.
Insight Path – Clear presentation helps readers understand practical guidance.
focused path – Practical idea, a clear focus defines momentum and keeps actions moving smoothly.
action fuels energy – Clear and practical, performing tasks sparks motivation naturally throughout the day.