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.
TrustedCartOnline – Highlights secure handling of transactions for a confident shopping experience.
enterprise sustainability planner – Encourages thinking beyond short-term gains to achieve lasting success.
efficient shopping portal – Organized categories make browsing comfortable and fast.
axivo – Clear and simple content, overall experience is pleasant
visit growthflowswithclarity – Straightforward pages, readable text, and overall pleasant experience
go to site – Quick load times, simple design, content feels approachable
discount shopping platform – Value-driven approach, likely to attract deal-seekers.
Business Alliance Hub – Offers clear insights into developing effective corporate partnerships.
this online shop – Smooth checkout and delivery updates kept me informed throughout.
DealWizard – Gave me clarity on all my options in no time.
web retailer – Navigation works well, and listings look professional and reliable.
mexto access – User-friendly layout and information that makes sense instantly
купить гражданство румынии
VisionAheadHub – Encourages exploring new ideas and anticipating long-term business and personal goals.
securebuyzone – Marketplace feels professional, inspires confidence for first-time shoppers.
progressmovesforwardnow access – Fast pages, readable content, and the layout is very intuitive
mavix central – Pleasant interface, all links worked and text easy to follow.
xavro homepage – Pleasant browsing, pages are easy to navigate and content is clear
click here – Quick access, organized sections, message is conveyed effectively
economical shopping hub – Prioritizes value, making it easier to discover good bargains.
storefront – Items were easy to browse, filtering helped me find what I needed fast.
BrixelHub – Layout feels clean, pages load fast, and navigation is smooth.
Pelixo Express – Clean interface, smooth navigation and content looks accurate.
Voryx Portal – Layout well-structured, pages load quickly, and shopping process smooth.
explorefuturedirections – Inspiring content, learning about future directions feels engaging and useful today.
Informed Growth Hub – Provides clarity that helps tackle difficult decisions with confidence.
NextGenOnlineBuying – Nice experience overall, navigation works smoothly and loads quickly everywhere.
Ulvaro Central – Smooth browsing, layout clear and overall experience user-friendly.
online retailer – Just discovered this site, fair deals and a simple checkout experience.
Kavion Path Shop – Browsing effortless, layout clean and product details straightforward.
SmartStrategyLearning – Encourages thoughtful learning practices aligned with strategic goals.
commercialbondsolutions – Professional and safe, designed to help businesses manage bonds effectively.
LinkQelaro – Smooth flow, everything is easy to reach.
Kavix Point – Simple layout, navigation intuitive and checkout process smooth.
progressmoveswithfocus zone – Pages are well-organized, making navigation effortless today
trusted resource – Well-structured sections, smooth experience, first look is promising
official clyra – Well-structured pages, thoughtful visuals, and a neat browsing experience
professional trust portal – Appeals to organizations prioritizing dependable business relations.
funnelfusion.click – Navigation felt smooth, found everything quickly without any confusing steps.
Yaveron Link – Navigation clear, products easy to find and checkout intuitive.
traffictide.click – Bookmarked this immediately, planning to revisit for updates and inspiration.
brivox access – No lag when opening pages, and the text remains clear
online retailer – Layout inspires trust, products load quickly, and ordering was effortless.
ProfessionalBondSolutions – Great platform overall, information is clear and genuinely helpful today.
Mavero Online – Fast loading, browsing seamless and product details easy to find.
Online Deal Finder – Offers practical tips for spotting the best deals and making wise purchases.
Korivo Express – Layout neat, shopping steps clear and pages load without delays.
ravion hub – Pages load quickly, categories are clear, and browsing feels effortless.
Vixor Zone – Fast-loading site, navigation intuitive, and content easy to follow.
перепланировка в москве pereplanirovka-kvartir3.ru .