How to switch to/from HTTPS using Apache as a proxy to Tomcat

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.

2,232 thoughts on “How to switch to/from HTTPS using Apache as a proxy to Tomcat

  1. La slot machine Buffalo Toro ha un RTP (Return to Player) del 94%, un valore leggermente inferiore alla media, che di solito si aggira intorno al 96%. In pratica, ciò significa che, considerando un lungo periodo di gioco, per ogni 100 euro spesi, la slot restituirà 94 euro ai giocatori. All’interno dell’interfaccia del nostro casinò, troverai cinque icone distinte per i vari giochi di casinò. Una di queste icone è denominata “Jackpot” e ti permetterà di visualizzare i jackpot in continua crescita con un solo clic. Facendo clic sull’icona “Slot” viene visualizzato un elenco completo di slot machine. Per iniziare a giocare a uno dei giochi slot, fai clic sulla rispettiva icona. Per ogni gioco selezionato, sullo schermo sono visualizzate alcune opzioni, tra cui “Maximum Duration Limit” (Limite di durata massimo) per impostare il tempo di gioco che desideri, e “Maximum Loss Limit” (Limite di perdita massimo) per gestire le tue finanze.
    https://jeroenwolfs.nl/atmosfera-piratesca-nella-slot-pirates-di-elk-studios-recensione-completa-per-giocatori-italiani/
    Il suo ideatore, Evolution, è uno dei nomi più blasonati tra i produttori di software per giochi da casinò e non tradisce le aspettative. Il gioco è frizzante, colorato e ricco di divertimento.  Commento * LeoVegas offre 50 giri gratis da 0,10€ ciascuno, con i primi 10 disponibili subito alla registrazione e i restanti 40 dopo la verifica del documento. Le vincite generate con i free spin si convertono immediatamente in bonus reale, che deve essere giocato una sola volta senza scadenza. La slot Sweet Bonanza di Pragmatic Play offre un’esperienza di gioco divertente con tema dolci e frutta. Con grafica di alta qualità e meccaniche semplici ma soddisfacenti, include bonus speciali come giri gratuiti e moltiplicatori. Il team professionale assicura un’esperienza di gioco fluida e sicura.

  2. Das Spielen im Book of Ra Paysafecard Casino bringt euch Sicherheit, volle Kostenkontrolle und schnelle Einzahlungen. Ihr müsst keine Bankdaten preisgeben und startet sofort. Besonders spannend: In Kombination mit Book of Ra Slots profitiert ihr zusätzlich von hoher RTP und attraktiven Bonusaktionen. Ein Bonus ist eine tolle Gelegenheit für neue Spieler, sich mit den verschiedenen Spielautomaten vertraut zu machen. Deswegen gibt es einen Willkommensbonus. Für alle anderen Slot-Spieler gibt es laufend Promotions und Bonuskampagnen. Bonus ohne Einzahlung ist ebenso beliebt wie Freispiele und Bonuscodes bei Einzahlung. Seit 2011 begeistert LeoVegas als preisgekröntes Casino, das schon mehr als eine Auszeichnung abstauben konnte – unter anderem als “Online Casino des Jahres”. Mit einem Angebot von über 300 Slots, ist in diesem paysafe Casino für jeden etwas dabei. Einzahlungen sind ab 10€ möglich, Auszahlungen ab 20€. Neukunden profitieren von einem verlockenden Willkommensbonus, der sowohl Bonusgeld als auch 100 Freispiele für Legacy of Dead beinhaltet.
    https://cakraslot88login.com/gates-of-olympus-ein-umfassender-review-fur-schweizer-spieler/
    16.11 Der Betreiber übernimmt keine Verantwortung für Tipp-, menschliche oder offensichtliche Fehler, die zu offensichtlichen Preisfehlern führen. In solchen Fällen werden alle Wetten für nichtig erklärt. This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data. 100% bis zu 500 € + 200 Freispiele Willkommen auf deiner persönlichen Achterbahn des Glücks und der Spannung, genau hier! Bist du bereit zu drehen, zu gewinnen und zu grinsen? Unser Mix aus Spielautomaten hat alles zu bieten: von herzerwärmenden Klassikern bis hin zu blendend neuen Einträgen. Aber es sind nicht nur Spiele; es ist deine Chance, in Momente einzutauchen, bei denen jeder Dreh zu einer Feier werden kann. Mühelos, spaßig und immer griffbereit—dein nächstes großes Abenteuer beginnt mit nur einem Klick. Probier es aus, denn das Glück ist mit den Mutigen!

  3. Um Gates of Olympus Echtgeld Slot zu spielen, müssen Sie sich zuerst in einem Online Casino anmelden. Sobald Sie damit fertig sind, gibt es nur einige Schritte, die Sie befolgen sollen: Gates Of Olympus hat sich seit seiner Veröffentlichung 2021 schnell als Flaggschiff von Pragmatic Play etabliert. Dieser Slot entführt Sie auf den Gipfel des Olymps, dem Reich der griechischen Götter. Zeus herrscht hier als absoluter Meister. Im Gegensatz zu traditionellen Spielautomaten verwendet Gates Of Olympus ein innovatives „Cluster Pays“-System. Gewinne entstehen, wenn 8 oder mehr identische Symbole irgendwo auf den Walzen erscheinen. Diese Mechanik, kombiniert mit leistungsstarken Multiplikatoren, schafft ein explosives Gewinnpotenzial. Der Entwickler hat noch nicht angegeben, welche Bedienungshilfen diese App unterstützt. Weitere Infos
    https://www.tucanoice.com/?p=410016
    Die schillernde Optik und das mitreißende Gameplay des Spielautomaten Gates of Olympus können fesselnd sein, aber denken Sie daran, dass selbst die mutigsten Helden einen Schlachtplan brauchen! Auch wenn die Jagd nach epischen Gewinnen Teil des Spaßes ist, ist verantwortungsbewusstes Spielen für ein wirklich unvergessliches Vergnügen unerlässlich. Hier sind einige einfache Tipps, die Ihnen helfen, sich in der aufregenden Welt von Gates of Olympus 1000 zurechtzufinden und mögliche Verluste zu minimieren. So können Sie sicherstellen, dass Sie die Walzen länger drehen (und hoffentlich viele Gewinne erzielen). Der Book of Dead Spielautomat ist einer der bekanntesten und beliebtesten Online Spielautomaten der Welt. Das spannende Thema der Schatzsuche im alten ägyptischen Reich gepaart mit der attraktiven Freispielrunde mit expandierenden Symbolen ist das Erfolgskonzept von Play’n GO, an das viele andere Softwares seit Jahren versuchen, anzusetzen. Falls auch Sie den Book of Dead Slot unbedingt ausprobieren möchten, können Sie bei uns ganz einfach auf die kostenlose Demoversion zugreifen und die abenteuerliche Jagd nach dem ägyptischen Totenbuch beginnen!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>