My current Application deployment is receiving traffic on HTTP port and Nginx redirect it to HTTPS. This is working fine.

Now we are planning to have another Nginx server act like a Load balancer to these existing Nginx server aka Upstreams.

Below is configurations that I was trying

upstream web_rack {
    server x.x.x.x;
server {

    location / {
        proxy_pass https://web_rack;

But getting 502 Bad Gateway error with below log:

2017/03/14 06:23:49 [error] 2402#2402: 5 SSL_do_handshake() failed (SSL: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol) while SSL handshaking to upstream, client:, server: , request: "GET / HTTP/1.0", upstream: "https://x.x.x.x:80/"

Thanks in advance.


It seems as if you there may be something wrong with your upstream or server settings.

Your error message shows that you are trying to speak https to the upstream on port 80: upstream: "https://x.x.x.x:80/".

The following question relates to yours, and provides an (almost) working config to achieve the same as what you are trying to do: Configure Nginx as reverse proxy with upstream SSL.

At very least, you may want to amend your upstream to read:

upstream web_rack {
    server x.x.x.x:443;
  • Oh my God! This question took me two hours! The Thank you very much for your answer! – ipcjs Jun 3 '17 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.