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.
Parenting Hub – Well-structured and friendly, content is simple to read and implement.
Saratoga Holiday Adventure – Lively and engaging, ride information is presented clearly for visitors.
ThirtyMale Explore – Fun and inspiring, layout guides visitors through content effortlessly.
Farm Knowledge – Informative and concise, provides practical insights into farm operations.
Mark Mackenzie Platform Info – Organized layout, content flows naturally for readers.
hellgate race guide – Organized layout, readers can quickly grasp all the event essentials.
Larkfest Moments – Lively content, finding schedules and details is effortless.
< Kionna West Online Portfolio – Professional and clear, navigating through the site feels effortless.
Newlyweds Travel Info – Event details are accessible, navigation is intuitive and easy.
Fullum & Holt Online – Navigation is seamless, content is well presented and professional.
FilAmericans Advocacy Network – Clear and accessible, pages inspire readers to learn and participate.
team tadros portal – Clear and concise, presenting priorities in a way that’s easy to follow.
coffee knowledge hub – Easy layout and concise content, makes learning fun and efficient.
Haunted Whollywood – Thrilling design, finding schedules and attractions is simple and enjoyable.
daybirdsyr updates portal – Clean layout, content is engaging and easy to browse at a glance.
local market hub – Easy experience, site navigation is intuitive and items are well-listed.
1911 PHL History – Informative site, layout makes historical content easy to follow and understand.
bennington arts updates portal – Vibrant and user-friendly, showcases community art clearly.
The Lux Noe Shop – Well-structured site, product info is easy to find and understand.
insightful clarity hub – Encourages stepping back and reviewing ideas carefully before moving ahead.
clarencedillonpl site – Clean design, content is easy to understand and access efficiently.
BLP Awards Hub – Well-laid-out content, event info comes across clearly and professionally.
Racing Team Updates – Easy-to-read pages, site showcases results and events effectively.
купить дайсон стайлер с насадками официальный сайт для волос цен… stajler-dsn.ru .
фен купить дайсон оригинал dn-fen-kupit.ru .
nsfeg info hub – Organized layout and relevant content make the site useful for newcomers.
Pinellas Learning Hub – Easy-to-read content, site presents information in a logical and user-friendly way.
garymasino center – Clear and professional layout, all key information is easy to locate.
пылесос дайсон беспроводной купить в москве цена pylesos-dn-1.ru .
hicks for missouri site – Straightforward and clear, navigation makes exploring campaign details simple.
дайсон официальный сайт фен цена fen-dn-kupit-13.ru .
дайсон официальный сайт фен цена fen-dn-kupit-12.ru .
Natasha Info Portal – Well-structured site, content is easy to digest and use.
george will musings – Smooth layout, reading feels natural and enjoyable.
фен dyson купить оригинал фен dyson купить оригинал .
Montes Leader – Informative site, pages are easy to follow and content is accessible.
ChicagoFrontRoom – Modern website design that feels inviting and easy to use.
Hotel Sleep & Cinema – Stylish and functional, site loads quickly and booking is hassle-free.
wexfordliteraryartsfestival.com – Beautiful festival site, content is engaging and easy to explore naturally.
Democracy Events – Smooth layout, information on events is easy to access and understand.
cateriarmccabe site – Well-organized, site makes it easy to find campaign objectives and info.
FocusGuide – Clear and concise layout supports understanding and long-term growth.
play-brary click zone – Bright, fun, and interactive, encouraged me to explore longer than usual.
GrowthEngine – Structured layout enhances comprehension and makes navigation smooth.
south by free noms site – Energetic and easy to browse, the event seems like a lot of fun.
Karen for Assembly 2026 – Professional site structure, details are clearly presented for visitors.
mandamurphy election hub – User-friendly interface, communicates essential information clearly.
Tobias Park Info – Friendly and inviting, site feels warm and content is easy to browse.
dibruno wine bottles – Easy-to-use website, products are clear and checkout is straightforward.
AlForneExperience – Well-laid-out sections help users find what they need instantly.