Using Nginx as Apache reverse proxy and receiving “502 Bad Gateway” error and, additionally have something like this in your error log file?
[error] SSL_do_handshake() failed (SSL: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol) while SSL handshaking to upstream, client: 0.0.0.0, server: www.domain.tld, request: “GET / HTTP/1.1”, upstream: “https://127.0.0.1:4343/”, host: “www.domain.tld”
Since you are using SSL, you obviously need dedicated IP address per vHost (this example clearly show the request has been sent to the localhost IP! You probably have the wrong IP set in proxy_pass statement).
1. Make sure the Apache vHost/site is responding on the non-standard port (browse to : https://www.domain.tld:4343).
2. If this is loading properly, then note the IP address contained within <VirtualHost 0.0.0.0:4343> of your SSL vHost, otherwise double check your Apache configuration.
3. Under your Nginx SSL vHost configuration, make sure the same IP address is in that statement “proxy_pass https://0.0.0.0:4343;“.