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.

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

  1. the blackjacks homepage canada, online casino instant withdrawal uk and
    traditional native united statesn gambling
    games, or best casino in london uk

    Have a look at my website … how do you play electronic roulette, Lloyd,

  2. Man moving is such a nightmare — dealt with this mess a few months ago and no kidding I wanted to give up. First you collect boxes then you realize how much junk youve accumulated. Friends recommended one company but I decided to dig deeper. Long story short if youre looking for good moving services around here dont just grab the first ad. Because local movers know the area especially with summer heat. For instance — spent a week reading reviews — and trust me it was totally worth it. So check this out where the best option popped up. movers nevada movers nevada That page alone gave me a clear picture. Everything is laid out clearly — no hidden surprises. Ended up booking and they handled it professionally. So yeah dont rush. Check the credentials. Quality service is priceless. Wish I had this info earlier

  3. So switching homes — always an adventure. Dealt with it not too long ago and honestly an absolute whirlwind. Everyone says its simple then the sheer volume hits you. One friend recommended X but I needed cold hard facts. Anyway: when youre after a solid moving company here weigh your options. Think about it: local expertise is half the battle — when time is money. What worked in my case — demanded itemized estimates — and Im not bluffing that effort was gold. Take a peek at this that made everything fall into place. nevada long distance movers https://movers-in-nevada-bng.com That one spot had it all laid out. Everythings clearly stated — no sneaky extras. Went ahead and booked through it and they outperformed expectations. Dont skip the fine print. Ask about their license. The right crew makes moving boring. May your move be smoother than mine

  4. So moving — what a headache. Been there not too long ago and honestly no picnic at all. Think its just packing then you see how much youve accumulated. One friend recommended X but I decided to dig properly. Cutting to the chase: when youre after reliable nevada moving services weigh your options. Think about it: nevada moving crews know the local drill — especially with narrow driveways. As for me — devoured reviews online — and no exaggeration I saved both cash and nerves. This link is worth your time that made everything fall into place. movers nevada movers nevada That single source cut the clutter. What you see is what you get — nothing off the books. Went ahead and booked through it and it was refreshingly smooth. So be thorough. Double-check equipment. Decent movers make a world of difference. May your move be smoother than mine

  5. Ребята кто ищет работу Задолбался я уже искать нормальную работу Работодатели только время тратят Короче реально рабочий вариант — вакансии казахстана с проживанием График удобный В общем сохраняйте себе — работа в казахстане для русских работа в казахстане для русских Не сидите без денег Перешлите тому кто ищет работу

  6. Ребята кто ищет работу Задолбался я уже искать нормальную работу Пересмотрел тысячи вакансий Короче нашел отличный сайт — вакансия в казахстане с обучением График удобный В общем там все вакансии — сайты поиска работы в казахстане https://rezyume.trudvsem.kz Не сидите без денег Перешлите тому кто ищет работу

  7. #if Инструкция: зайти в кракен через тор браузер Хаюшки всем Фраза игра в кракена коды интересует тех кто хочет ускорить процесс прохождения. Настоящие игра в кракена коды помогают открывать уровни ресурсы и бонусы. Пользователи обсуждают где найти проверенные игра в кракена коды и как правильно их использовать. Кракен маркетплейс onion доступен без ограничений. кракен регистрация кракен телеграмм отзывы кракен маркет телефон Проверенные ссылки для входа на маркетплейс КРАКЕН: • Для пользователей из г. Челябинск доступно рабочее зеркало: вход на кракен июль июнь 2025 — kraken2vhod.cc • Запасная ссылка для остальных регионов: список актуальных ссылок кракен — krakenactual.cc Задавайте вопросы если возникнут проблемы с доступом или входом на КРАКЕН. Проверял лично все актуальные зеркала работают стабильно в 2026 году. #else Кракен тор вход зеркало рабочее Всем салют Фраза кракен телеграм маркетплейс популярна среди тех кто интересуется торговыми площадками. Настоящий кракен телеграм маркетплейс подтверждается сообществом и администрацией. Кракен площадка торговая собрала магазины в одном месте. телеграм бот кракен сайт кракен как войти если забыл пароль кракен вход официальная ссылка Проверенные ссылки для входа на маркетплейс КРАКЕН: • Для пользователей из г. Челябинск доступно рабочее зеркало: вход на кракен июль июнь 2025 — kraken2vhod.cc • Запасная ссылка для остальных регионов: актуальная ссылка кракен — krakenactual.cc Оставляйте комментарии если возникнут проблемы с доступом или входом на КРАКЕН. Проверял лично все актуальные зеркала работают стабильно в 2026 году.

  8. Ugh moving — such a grind. Dealt with this mess a couple months back and honestly I wanted to cry. You start with boxes then suddenly youre drowning in clutter. Someone at work mentioned a company but I didnt trust them blindly. Anyway when youre hunting for movers in nevada compare at least three options. Look local nevada movers know the routes — when youre moving across town. Like I did — asked about insurance and extra fees — and Im not making this up it was 100 worth it. By the way this is the source that made everything click. moving companies nevada moving companies nevada Honestly that list saved me hours of digging. No guessing games — no hidden junk fees. Scheduled my move that week and the process was smooth. Do your due diligence. Ask about equipment. The right company makes moving boring. Hope this points you in the right direction

  9. Слушайте кто знает Близкий человек уже несколько дней в запое Жена в истерике Таблетки не помогают Короче только это реально спасло — вывод из запоя люберцы с выездом Поставили капельницу с детоксикационным раствором В общем телефон и цены тут — вывод из запоя недорого в люберцах https://chastnyj.vyvod-iz-zapoya-na-domu-moskva.ru Вывод из запоя на дому — это реальный выход Перешлите тем кто в такой же ситуации

  10. Выбирал приличного букмекера для спорта. Протестировал много сайтов но всё-таки пришёл на 1вин. Друзья посоветовали — решил глянуть. И вот что понял — достойный подход. Роспись плотная кешаут есть. Короче если присматриваете контору — советую ознакомиться. Здесь всё подробно. 1win рабочее зеркало 1win рабочее зеркало Там и про бонусы — без лишней воды. И сам по этой инструкции — на удивление просто. Быстро оформляется документы быстро принимают. Плюс зеркало всегда работает. Так что не тяните. Спортивного везения

  11. Ugh moving — what a nightmare. I just went through it a couple months back and honestly it was pure chaos. You start with boxes then suddenly youre drowning in clutter. Someone at work mentioned a company but Im glad I double-checked. Long story short when youre hunting for movers in nevada do your homework first. Look experienced crews make all the difference — particularly on narrow streets. I personally — read reviews for hours — and believe me I dodged a bullet. By the way this is the source that helped me decide. moving companies nevada moving companies nevada That one page saved me hours of digging. Rates are transparent — no hidden junk fees. Ended up going with their top pick and the process was smooth. So yeah dont rush. Check their license. Quality service is gold. Hope this points you in the right direction

  12. Люди подскажите Брат снова сорвался Соседи стучат в стену Таблетки не помогают Короче только это реально спасло — вывод из запоя круглосуточно люберцы профессионально Сняли ломку и стабилизировали состояние В общем жмите чтобы сохранить — вывод из запоя на дому недорого в люберцах https://chastnyj.vyvod-iz-zapoya-na-domu-moskva.ru Вывод из запоя на дому — это реальный выход Перешлите тем кто в такой же ситуации

  13. Выбирал нормальную контору для беттинга. Перепробовал кучу вариантов но в конце концов выбрал на 1win. Друзья посоветовали — решил глянуть. И вот что понял — качественный сервис. Линия широкая выплаты оперативные. Суть в том если хотите нормально ставить — смело заходите. Там всё расписано. 1win бонус 1win бонус И про условия вывода — комплексно. Так же всё сделал — никаких проблем. Быстро оформляется честно скажу. Если основной сайт блокнут — есть выход. Не думайте долго. Спортивного везения

  14. Moving is always a hassle — had to deal with this a recently and no joke I almost lost it. It seems easy at first then it hits you out of nowhere. Coworker used someone else but I wasnt going to trust blindly. Long story short: when youre looking for movers in nevada compare at least a few. Because experienced crews make everything easier — especially with long distances. What I did — asked about insurance and extra fees — and trust me it was absolutely worth it. Check this out that helped me lock in a good choice. nevada moving company nevada moving company Honestly that list saved hours of scrolling. Prices are up front — clear breakdowns. Scheduled the whole move and it went smoothly. Be smart about this. Confirm the schedule. Quality service is worth every dollar. Good luck with your move

  15. Oh man moving is brutal. Went through it just last summer and honestly it was a total circus. First you grab some boxes then it hits you how much crap you own. A friend hired a different crew but I dug deeper myself. Basically: when youre on the hunt for decent moving services out here do your research up front. Look experienced crews are worth every penny — when youre moving across state lines. For example — made like five calls — and believe it or not I avoided a huge headache. So heres the link that put all the info in one place. nevada moving services https://movers-in-nevada-xhr.com Just that link saved hours of digging. No guessing games — no hidden charges. Scheduled my whole move and they killed it. Be smart about it. Ask about equipment. Quality service is everything. Hope this helps you out

  16. Люди подскажите Муж просто потерял себя Родственники не знают что делать Таблетки не помогают Короче единственное что вытащило из запоя — вывод из запоя на дому круглосуточно анонимно Приехали через 40 минут В общем телефон и цены тут — вывод из запоя на дому круглосуточно в люберцах https://chastnyj.vyvod-iz-zapoya-na-domu-moskva.ru Не ждите пока станет хуже Перешлите тем кто в такой же ситуации

  17. Moving is seriously stressful — had to deal with this a while back and honestly I almost lost it. First you grab some boxes then youre buried under piles of stuff. Coworker used someone else but I wanted to verify everything. Anyway: when youre looking for reliable moving services around here compare at least a few. The thing is companies here handle the weather better — especially for cross-town moves. What I did — asked about insurance and extra fees — and believe me I avoided a huge headache. Check this out that helped me lock in a good choice. movers in nevada movers in nevada Honestly that list cut my search in half. Everything is transparent — no surprises. Booked through that link and it went smoothly. So dont rush it. Ask about equipment. Quality service is worth every dollar. Hope this helps

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>