nginx https反向代理 tomcat

前端nginx配置

  server {
       listen       80;
       server_name  localhost;
   
       listen       443 ssl;
       ssl_certificate   /usr/local/nginx/sslkey/xxxxxx.pem;
       ssl_certificate_key  /usr/local/nginx/sslkey/xxxxxxxx.key;
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
        proxy_pass  http://xxx;
        proxy_buffers 4 1024k;
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Real-IP $remote_addr;
        }

后端tomcat 配置

 <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
           uRIEncoding="utf-8"
               redirectPort="443" 
               proxyPort='443'/>
       <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

     <Valve className="org.apache.catalina.valves.RemoteIpValve"
                       remoteIpHeader="x-forwarded-for"
                       remoteIpProxiesHeader="x-forwarded-by"
                       protocolHeader="x-forwarded-proto" />

        <!-- Access log processes all example.

END!

原文地址:https://www.cnblogs.com/changbo/p/6088792.html