proxying to upstream port based on scheme

Anoop Alias anoopalias01 at gmail.com
Wed Oct 5 13:04:06 UTC 2016


I have an httpd upstream server that listen on both http and https at
different port and want to send all http=>http_upstream and https =>
https_upstream

The following does the trick

#####################
if ( $scheme = https ) {
set $port 4430;
}
if ( $scheme = http ) {
        set $port 9999;
}

location / {

    proxy_pass   $scheme://127.0.0.1:$port;
}
#####################

Just wanted to know if this is very inefficient (if-being evil) than
hard-coding the port and having two different server{} blocks for http and
https .

Thanks in advance.



-- 
*Anoop P Alias*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20161005/aa2772f4/attachment.html>


More information about the nginx mailing list