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.
explore yavex – Smooth navigation, everything loads quickly and feels intuitive.
glintgarden.shop – A gardener’s paradise, filled with the best products for every need!
Auroriv portal – Sleek design paired with a great assortment of products.
Bento Box Corner – So many beautiful options for lunchboxes, I love the modern look.
1win plinko pul ishlash http://www.1win5766.help
Interesting finds – I like how new items keep popping up naturally.
coppercitrine.shop – I can always find something special here, love the modern copper designs.
charmcartel.shop – The perfect place for trendy accessories, easy to navigate and shop.
crystalcorner2.shop – A must-visit for crystal lovers, great quality gems and beautiful designs.
florafreight.shop – Love the selection of vibrant flowers, a must-see for all garden lovers.
xylix online – Pleasant experience, content is well-organized and pages load fast.
1win Oʻzbekiston rasmiy domen 1win Oʻzbekiston rasmiy domen
chicchisel.shop – High-quality tools that I can trust, this is my go-to store for all things DIY!
nevrix portal link – Pleasant experience, navigation is smooth and information is clearly visible.
visit zexarotrust – Straightforward layout with information that feels easy to absorb.
Bloom Barrel shop – Lovely floral-inspired selection with a smooth browsing experience.
Vehicle essentials – Great for finding car products quickly and easily.
check this out – Short browsing session, layout feels intuitive and visually appealing.
Floral Wonderland – Beautiful flowers and easy-to-navigate site, a great shopping experience.
xorya explore – Landed here randomly, interface is neat and details are very easy to understand.
glintvogue.shop – Amazing collection of fashion-forward items, a great place to shop!
coralcrate.shop – Unique and stylish products, the site layout makes it super easy to find what you need.
1win hozirgi mirror https://1win5766.help
browse vixarobonding – Clear headings, smooth browsing, and information is easy to find.
Interior upgrade – Easy way to make a room feel more stylish.
charmcartel.shop – Gorgeous accessories and great site design, very simple to shop.
curtaincraft.shop – Stylish curtains and textiles, this site has something for every taste.
freshfinder.shop – A great place to discover new and exciting products, love browsing here!
электрические гардины для штор elektrokarniz5.ru .
1win MTN Mobile Money http://1win5744.help
карниз моторизованный elektrokarnizy750.ru .
visit plixo – Smooth navigation, content loads quickly and pages feel user-friendly.
Bloom Beacon treasures – Unique gifts and stylish decor, simple to navigate.
онлайн школа 11 класс онлайн школа 11 класс .
Briovanta Marketplace – Love this place for unique items and easy navigation, a must-visit store.
Bag hub – Always discovering stylish products I can’t wait to try.
qulavoholdings hub – Clean layout, content is easy to follow and pages load smoothly.
this trustco page – Well-arranged pages convey reliability and a polished look.
covecrimson.shop – Excellent selection of bold, high-end products. Always a great experience shopping here.
электронный карниз для штор elektrokarnizy-dlya-shtor1.ru .
trustco overview – Everything is clearly structured, reliable, and easy to navigate.
charmcartel.shop – Fantastic collection of trendy accessories, browsing the site is a breeze.
gardengalleon.shop – Wonderful site for all your gardening needs, the items are practical and well-designed.
cypresschic.shop – Beautiful items and an incredibly easy-to-use site for shopping.
Clean shopping hub – Nice balance of simplicity and solid pricing.
goldenget.shop – Excellent selection of premium items, shopping here is a breeze!
1win poker https://1win5744.help/
zarvo explore – Layout is tidy, navigation is intuitive and pages load without issues.
cinnamoncorner.shop – A great place to shop for one-of-a-kind items that stand out from the rest!
Blue Quill style – Love the range of items and the clean, modern design.