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.

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

  1. Informazioni di base sul gioco Esplora le ultime slot machine gratis senza scaricare aggiunte di recente al nostro parco di giochi senza la necessità di scaricare nulla. Scopri le novità più avvincenti e divertenti, pronte per offrirti un’esperienza di gioco senza pari Tutto ciò ha contribuito a raggiungere un notevole record di sicurezza. Anche se non più utilizzato per l’addestramento militare, l’L-29 Delfin è ancora popolare tra gli operatori civili di tutto il mondo, dal volo personale agli airshow e a competizioni come la gara aerea di Reno. Cercare di imbrogliare Gates of Olympus o qualsiasi altra slot online non è solo eticamente discutibile, ma anche praticamente improbabile. Le slot online sono controllate da sofisticati generatori di numeri casuali (GNA), garantendo che ogni giro sia indipendente e imparziale. I GNA sono progettati meticolosamente per garantire che ogni risultato sia completamente casuale, salvaguardando così l’equità del gioco e mantenendo un ambiente di gioco imparziale.
    https://murano.com.py/?p=6761
    I giochi che troverai su Pokerstars Casino sono quelli sviluppati da software house leader nel settore come Big Time Gaming, Evolution Gaming, iSoftBet, Leander Games, Microgaming, Netent, Play n go, Playtech, Pragmatic Play, Quickspin, Red Tiger Red Tiger, Thunderkick, Yggdrasil. Per saperne di più sui nostri giochi cialis las vegas: order cialis soft tabs – stockists of cialis OFFERTA 1. Effettua una puntata di €20 per ricevere un bonus casinò istantaneo di €40.OFFERTA 2. Effettua una puntata di €50 per ricevere un bonus casinò istantaneo di €100.OFFERTA 3. Effettua una puntata di €100 per ricevere un bonus casinò istantaneo di €200. Content À l’intérieur des tours bonus Jeux et fournisseurs de machines à sous Big Bass Bonanza Casino : Où Jouer ? Profiter des Bonus de Tours Gratuits Big Bass Bonanza : Fonctionnalités de la Machine à Sous Cela peut se produire sur n’importe quel tour gratuit, à tout moment pendant le round bonus. Les rounds

  2. Gates of Olympus bonuses can be big. Players can also activate additional free spins. In addition, the Gates of Olympus RTP, which is 96.50% flat, is considered one of the highest. These basic facts will tell you what to expect from this Pragmatic Play slots game. But the most valuable unclaimed ticket on the list, on average. Gates of olympus strategy guide this is because the bonus pot symbols are scatters, the RTP is around 93% making its odds of winning similar to Slots and slightly lower than live casino table games like Online Blackjack or Online Roulette. Hours of operation: Before we dive into the gameplay, let’s take a quick look at the key details of the Gates of Olympus slot. The following table provides an overview of the game’s specifications. “Gates of Olympus 1000 – Pragmatic Play” is packed with features that enhance its excitement and winning potential. One of the standout features is the “multiplier mechanic”, which is activated by no other than Zeus. (You read it right.) During the game, the god of thunder can randomly throw multipliers onto the grid, ranging from 2x to 500x. These multipliers are added to any winning clusters they land on, significantly boosting the payouts.
    https://mentari777.com/is-chicken-road-by-inout-legit-an-in-depth-review-for-canadian-players/
    Although when customers hit one of bonus features of free play Gates of Olympus 1000 like tumble attribute or free spins round the picture changes its color scheme. If during the basic game the sky looks like its evening sunset with purple, pink and orange shades then during the bonus rounds we can clearly see the night sky full of stars and with a full moon. The colors become darker with dark blue and green colors prevailing, they look very alike the Northern lights. Gates of Olympus Super Scatter is really easy to understand. While most other slot games have specific paylines and symbols that need to line up to pay out, that’s not the case here. You can get a win no matter where on the grid the matching symbols land, as long as there are enough of them. You’ll need at least eight of any of the standard symbols to win.

  3. стартовал наш новый https://utgardtv.com IPTV?сервис созданный специально для зрителей из СНГ и Европы более 2900 телеканалов в высоком качестве HD / UHD / 4K. Пакеты по регионам: Россия Украина Беларусь Кавказ Европа Азия. Фильмы Спорт Музыка Дети Познавательные. Отдельный пакет 18

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>