multiple https proxy_pass to diffrent apache server

Valentin V. Bartenev ne at vbart.ru
Sat Jan 14 16:33:45 UTC 2012


On Saturday 14 January 2012 19:17:37 Jelle de Jong wrote:
> Hello everybody,
> 
> The relevant part of the config: http://paste.debian.net/hidden/9d3d8f16/
> 
> I want to proxy pass port 443 based on the server_name to different
> Apache servers, anybody knows how should I do this?
> 
> Summary of the config: (see the above pastebin for more info)
> 
> server {
>     listen      443;
>     server_name calendar.powercraft.nl;
>     ssl         on;
>     ssl_certificate     /etc/ssl/certs/certificate.pem;
>     ssl_certificate_key /etc/ssl/certs/privatekey.pem;
>     keepalive_timeout   70;
>     location / {
>         proxy_redirect      off;
>         proxy_pass          https://192.168.24.66/;
>     }
> }
> 
> server {
>     listen      443;
>     server_name webmail.tuxblogger.nl;
>     ssl         on;
>     ssl_certificate     /etc/ssl/certs/certificate.pem;
>     ssl_certificate_key /etc/ssl/certs/privatekey.pem;
>     location / {
>         proxy_redirect      off;
>         proxy_pass          https://192.168.24.67/;
>     }
> }
> 
> I want to add several more server_names if possible.
> 

Probably something like this would work:

 map $host $backend {
     calendar.powercraft.nl  192.168.24.66;
     webmail.tuxblogger.nl   192.168.24.67;
 }

 server {
    listen      443;
    server_name calendar.powercraft.nl webmail.tuxblogger.nl;

    ssl on;
    ssl_certificate     /etc/ssl/certs/certificate.pem;
    ssl_certificate_key /etc/ssl/certs/privatekey.pem;

    keepalive_timeout   70;

    location / {
        proxy_pass  https://$backend/;
    }
 }

 
 wbr, Valentin V. Bartenev




More information about the nginx mailing list