I have a standard reverse proxy, with nginx and Tomcat 8.
I want nginx to handle encryption, but still inform tomcat whether the connection is secure or not.
i have
location /{
listen 80;
proxy_pass http://backend:8080;
}
location /{
listen 443 ssl;
proxy_pass https://backend:8443;
}
tomcat has the following config:
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" maxThreads="150" SSLEnabled="false" scheme="https" secure="true" clientAuth="false" URIEncoding="UTF-8"/>
however I am getting error
SSL_do_handshake() failed (SSL: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol) while SSL handshaking to upstream, client: 185.3.147.237, server: backing, request: "GET /favicon.ico HTTP/1.1", upstream: "https://127.0.0.1:8443/favicon.ico", host: "
How do I tell nginx that connection to backend is not encrypted even though the address starts with https?
http://backend:8443
(ie without the https, port can remain the same as that's how its defined in Tomcat). Your Tomcat connector config already says that anything coming over that connector is secure due to thescheme"https"
andsecure="true"
, so Tomcat understands its secure.proxyName
andproxyPort
to let Tomcat know there is a proxy, this should take care of the redirect issue.