Thursday, September 15, 2016

ssl - Single http/https server block in nginx with upstream https and upstream http

Our current nginx setup handles http/https with a solution similar to the one specified in this answer



nginx.conf




http {
upstream backend {
server backend.com
}
upstream backend_ssl {
server backend.com:443
}
}



sites-available/domain.conf



server {
listen 80;
server_name www.domain.com
location /a/update {
proxy_pass http://backend;
}
}



sites-available/domain_ssl.conf



server {
listen 443 ssl;
server_name www.domain.com
location /a/update {
proxy_pass https://backend_ssl;
}

}


I'd like to modify this to use the solution mentioned in the official nginx docs for using a single http/https server block. How do I do this in the above scenario as even though the location block url is same, the proxy_pass directive parameter differs for http and https.

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...