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.
leadgenius.click – Appreciate the typography choices; comfortable spacing improved my reading experience.
growtharena.click – Navigation felt smooth, found everything quickly without any confusing steps.
brandshine.click – Bookmarked this immediately, planning to revisit for updates and inspiration.
brandreach.click – Bookmarked this immediately, planning to revisit for updates and inspiration.
clickreach.click – Bookmarked this immediately, planning to revisit for updates and inspiration.
growthmind.click – Loved the layout today; clean, simple, and genuinely user-friendly overall.
digitalrise.click – Pages loaded fast, images appeared sharp, and formatting stayed consistent.
leadlaunch.click – Bookmarked this immediately, planning to revisit for updates and inspiration.
advisionpro.click – Color palette felt calming, nothing distracting, just focused, thoughtful design.
adspherepro.click – Bookmarked this immediately, planning to revisit for updates and inspiration.
adsprint.click – Loved the layout today; clean, simple, and genuinely user-friendly overall.
brandfuel.click – Content reads clearly, helpful examples made concepts easy to grasp.
promopath.click – Found practical insights today; sharing this article with colleagues later.
adreachpro.click – Appreciate the typography choices; comfortable spacing improved my reading experience.
marketpilot.click – Content reads clearly, helpful examples made concepts easy to grasp.
marketfuel.click – Content reads clearly, helpful examples made concepts easy to grasp.
clickscale.click – Found practical insights today; sharing this article with colleagues later.
trafficsphere.click – Found practical insights today; sharing this article with colleagues later.
adlift.click – Mobile version looks perfect; no glitches, fast scrolling, crisp text.
clickgurus.click – Overall, professional vibe here; trustworthy, polished, and pleasantly minimal throughout.
clickprohub.click – Navigation felt smooth, found everything quickly without any confusing steps.
seostreampro.click – Loved the layout today; clean, simple, and genuinely user-friendly overall.
clickforce.click – Found practical insights today; sharing this article with colleagues later.
brandmagnet.click – Mobile version looks perfect; no glitches, fast scrolling, crisp text.
clickenginepro.click – Pages loaded fast, images appeared sharp, and formatting stayed consistent.
seojet.click – Appreciate the typography choices; comfortable spacing improved my reading experience.
trafficstream.click – Content reads clearly, helpful examples made concepts easy to grasp.
trafficmind.click – Bookmarked this immediately, planning to revisit for updates and inspiration.
promobridge.click – Bookmarked this immediately, planning to revisit for updates and inspiration.
marketscope.click – Pages loaded fast, images appeared sharp, and formatting stayed consistent.
seotrack.click – Mobile version looks perfect; no glitches, fast scrolling, crisp text.
promocloud.click – Loved the layout today; clean, simple, and genuinely user-friendly overall.
digitaltrack.click – Bookmarked this immediately, planning to revisit for updates and inspiration.
clickgrow.click – Content reads clearly, helpful examples made concepts easy to grasp.
seopath.click – Pages loaded fast, images appeared sharp, and formatting stayed consistent.
marketrise.click – Pages loaded fast, images appeared sharp, and formatting stayed consistent.
webimpact.click – Found practical insights today; sharing this article with colleagues later.
brandtrail.click – Content reads clearly, helpful examples made concepts easy to grasp.
digitalpeak.click – Mobile version looks perfect; no glitches, fast scrolling, crisp text.
seoforce.click – Pages loaded fast, images appeared sharp, and formatting stayed consistent.
adtrend.click – Color palette felt calming, nothing distracting, just focused, thoughtful design.
vavada casino pl Inwestycja w dzialke w tym regionie to doskonaly sposob na polaczenie przyjemnego z pozytecznym. Dzieki rozwijajacej sie infrastrukturze i rosnacemu zainteresowaniu turystow ceny dzialek stopniowo wzrastaja. Coraz wiecej osob docenia spokoj i piekno przyrody jakie oferuja Beskidy. #### 2. Gdzie szukac najlepszych ofert dzialek? Wybor odpowiedniej lokalizacji zalezy od indywidualnych potrzeb i budzetu. Warto sprawdzic profesjonalne strony internetowe takie jak dzialki-beskidy.pl ktore prezentuja sprawdzone oferty. Przed zakupem nalezy dokladnie przeanalizowac dostepnosc mediow i warunki zabudowy. Wazne jest aby sprawdzic czy dzialka ma dostep do wody i pradu co wplywa na wygode uzytkowania. #### 3. Jakie korzysci daje posiadanie dzialki w Beskidach? Nieruchomosc w gorach to nie tylko inwestycja finansowa ale rowniez szansa na poprawe jakosci zycia. Dzialka w Beskidach moze stac sie zrodlem dochodu jesli zdecydujemy sie na wynajem turystom. Dodatkowo region ten oferuje wiele atrakcji takich jak szlaki turystyczne i stoki narciarskie. Coraz wiecej osob wybiera te lokalizacje ze wzgledu na dobrze rozwinieta baze rekreacyjna. #### 4. Jak przygotowac sie do zakupu dzialki? Przed podjeciem decyzji warto skonsultowac sie z prawnikiem i geodeta. Dobrze jest sprawdzic historie nieruchomosci i upewnic sie ze nie ma zadnych obciazen. Wazne jest rowniez okreslenie swojego budzetu i planow zwiazanych z zagospodarowaniem terenu. Niektore oferty pozwalaja na rozlozenie platnosci co ulatwia inwestycje. — ### Szablon Spinu 1. Dlaczego warto kupic dzialke w Beskidach? – Malownicze krajobrazy Beskidow przyciagaja zarowno turystow jak i przyszlych mieszkancow. – Dzialki w Beskidach to coraz czesciej wybierana lokata kapitalu przez swiadomych inwestorow. 2. Gdzie szukac najlepszych ofert dzialek? – Dobrym rozwiazaniem jest skorzystanie ze sprawdzonych stron internetowych takich jak dzialki-beskidy.pl. – Przed zakupem nalezy zweryfikowac dostepnosc mediow i mozliwosci zabudowy. 3. Jakie korzysci daje posiadanie dzialki w Beskidach? – Wlasny kawalek gorskiej przestrzeni pozwala na ucieczke od miejskiego zgielku. – Region oferuje wiele aktywnosci od wedrowek po gorach po jazde na nartach. 4. Jak przygotowac sie do zakupu dzialki? – Konsultacja z geodeta pomoze uniknac problemow z granicami nieruchomosci. – Niektore oferty umozliwiaja elastyczne formy platnosci co moze byc korzystne.
advista.click – Loved the layout today; clean, simple, and genuinely user-friendly overall.
seoconnect.click – Loved the layout today; clean, simple, and genuinely user-friendly overall.
trafficrise.click – Loved the layout today; clean, simple, and genuinely user-friendly overall.
growthcraft.click – Bookmarked this immediately, planning to revisit for updates and inspiration.
seoorbit.click – Color palette felt calming, nothing distracting, just focused, thoughtful design.
growthflow.click – Navigation felt smooth, found everything quickly without any confusing steps.
seostream.click – Navigation felt smooth, found everything quickly without any confusing steps.
seohero.click – Loved the layout today; clean, simple, and genuinely user-friendly overall.