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.
partnerhub – Easily find reliable partners and expand your business network.
claritypathcenter – Guidance makes achieving goals straightforward and less confusing.
growthclarityfocus – Practical advice, attention to detail strengthens growth outcomes.
pathshaper – Nice advice, focused actions define direction and support long-term goals.
stepbystepgrowth – Very helpful, breaking progress into steps makes it realistic and achievable.
forwardstrategy – Inspiring ideas, focusing on a structured path boosts forward momentum effectively.
elitevisionnetwork – Great, network presents itself as both prestigious and collaborative.
motionbeacon – Insightful guidance keeps progress steady and results consistent.
ideaengine – Directional clarity helps ideas turn into practical results efficiently.
progresspilot – Anchored clarity ensures consistent growth and reliable results.
trustandvaluealliance – Strong perspective, trust and core values make partnerships more resilient.
forwardgrowthtips – Great insights, following structured growth paths feels manageable and easy.
purpose driven growth – Solid insights, intentional growth avoids unnecessary distractions.
momentumengine – Clear steps help build momentum and maintain consistent progress throughout projects.
energypath – Useful guidance, focusing effectively moves energy toward achieving outcomes faster.
collaborativepowergroup – Very practical, collaboration with powerful groups enhances opportunities and drives shared growth effectively.
motionengine – Very useful, logical explanations help link ideas and action smoothly.
jointventureshub – Supports coordinated efforts and strategic partnerships that thrive.
progressmindset – Helpful insights, this forward-thinking engine helps organize ideas into actionable steps efficiently.
motionnavigatorhub – Guidance supports focus and ensures actions are productive.
alignedvisionbond – Very helpful, alignment around a central vision ensures consistency in execution.
progresssignal – Clear signals guide actions and help projects move forward smoothly.
directionhub – Very insightful, these signals provide a central guide for decision-making.
flowengine – Energy created from focus keeps work moving forward predictably.
actionableideas – Great advice, transforming concepts into action is explained in a simple way.
forwardengine – Structured frameworks simplify planning and help tasks move forward effectively.
momentumpath – Useful guidance, clarity on next steps makes building momentum easier.
alliancenetworkcircle – Strong, collaborative circles provide structure for partnerships to thrive and expand.
strategicleadersbond – Very practical, strategic leadership connections focus on meaningful, professional engagement.
?Necesitas mudarte? https://trasladoavalencia.es ?Necesitas una mudanza rapida segura y sin complicaciones en Valencia? Ofrecemos servicios profesionales de transporte y mudanzas para particulares y empresas. ?Solicita un presupuesto gratuito y disfruta de nuestro servicio de calidad
stepforwardhub – Helpful guidance, each deliberate action contributes to a smooth path forward.
successhub – Build partnerships that consistently achieve tangible results.
focusmotioncenter – Concepts are clear and practical, helping implement strategies effectively.
unitynetwork – Clear alliance message, partnerships seem purposeful and mutually supportive.
focusengine – Correct steps energize progress and support consistent achievement of goals.
Планируешь перевозку? перевоз оборудования удобное решение для переездов и доставки. Погрузка транспортировка и разгрузка в одном сервисе. Работаем аккуратно и оперативно подбираем машину под объём груза. Почасовая оплата без переплат.
guidedpath – Inspiring guidance, signals provide subtle directions that enhance progress and planning.
futuregrowthcircle – Insightful, messaging highlights adaptability, forward planning, and value creation.
progresscompass – Thoughtful guidance helps transform ideas into clear, actionable steps.
growthinsightnetwork – Helpful, following structured growth methods makes results more predictable and reliable.
partnerconnect – A platform for reliable collaboration and successful joint efforts.
motionfocuscenter – Practical ideas, helps maintain momentum while managing projects.
planbeacon – Regular action keeps projects progressing and momentum steady throughout.
internationalteamlink – Very practical, connections here foster teamwork and cross-border collaboration effectively.
intentionalnetwork – Strategic clarity stands out, connections appear carefully planned.
collaborationzone – A space for creating strong, lasting professional collaborations.
Каталог мини-приложений tgram.link и ботов Telegram 2026: кликеры TON-игры AI-сервисы и крипто-инструменты. Обзоры рейтинги инструкции и обновления. Подбор по категориям безопасности и реальной пользе — всё в одном месте.
Professional Synergy Bond – A creative idea for encouraging collaboration among experts.
professionalpathways – Practical tools and connections to expand influence and career potential.
progressbeacon – Maintaining focus amplifies momentum and helps reach milestones on time.