logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: ProxyPass - How to reduce the amount of virtual hosts
Author
MofaBertram



Joined: 30 Dec 2024
Posts: 1

PostPosted: Mon 30 Dec '24 22:52    Post subject: ProxyPass - How to reduce the amount of virtual hosts Reply with quote

Hi!

I'm running an Apache as a reverse proxy for several Tomcat backends. There's no load ballancing. Each name based virtual host serves one Tomcat via ProxyPass/mod_jk. Since I want to setup a new linux machine I realzied that I'm currently running 30 virtual hosts and because I also want to serve https on the new one the amount of virtual hosts doubles.

So I started to look for another setup where I could reduce the ammount of virtual hosts. I looked for a setup where I can serve all backends with 2 virtual hosts only but the decision for the correct backend still must be made on the virtual host servername. One for http and one for https. My first attempt was to try if-conditions on the servernames but ProxyPass directives are not allowed within if-conditions.

Then I looked for other config setups but honestly I did not found one.

Does anyone have a tip?

Regards
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7381
Location: Germany, Next to Hamburg

PostPosted: Fri 03 Jan '25 10:28    Post subject: Reply with quote

For HTTP/80 you could use a VirtualHost _default_:80 and pass on the correct host.
For SSL you need a correct name for a valid certificate unless you have a multidomain certificate.

a more complex solution would be to use mod_rewrite.

https://blog.brakertech.com/apache-proxypass-with-dynamic-hostname/

or from freebsd forum[2]

Code:

RewriteEngine On
        RewriteMap d2u "prg:/var/www/html/whatever.sh"
        RewriteRule .* - [E=ZPROXY:${d2u:%{HTTP_HOST}|dynamic.domain.name}]
        ProxyPreserveHost On
        ProxyPassInterpolateEnv On
        ProxyPassReverse / https://${ZPROXY}:443/ interpolate
        ProxyPass / https://${ZPROXY}:443/ interpolate



Or use mod_proxy_express[1]

[1] https://httpd.apache.org/docs/2.4/mod/mod_proxy_express.html

[2] https://forums.freebsd.org/threads/proxy-pass-to-dynamic-dns.81328/
Back to top


Reply to topic   Topic: ProxyPass - How to reduce the amount of virtual hosts View previous topic :: View next topic
Post new topic   Forum Index -> Apache