nginx 做 tomcat项目 http && https

Tomcat配置:  /xxxx/xxx/conf/server.xml

<Server port="7777" shutdown="SHUTDOWN">          #端口可自定义

............

<Connector port="443" protocol="HTTP/1.1"
    connectionTimeout="20000"
    redirectPort="8443"
    proxyPort="443"/>

..................

<Connector port="7779" protocol="AJP/1.3" redirectPort="8443" />                   #7779端口可自定义

...................

<Engine name="Catalina" defaultHost="localhost">

...................

<Host name="localhost" appBase="webapps"
  unpackWARs="true" autoDeploy="true">
<Valve classNmae="org.apache.catalina.valves.RemoteIpValve"
    remoteIpHeader="x-forwarded-for"
    remoteIpProxiesHeader="x-forwarded-by"
    protocolHeader="x-forwarded-proto"/>
<Context path="" docBase="/datadisk/tomcat9/tomcat9-2/webapps/xxx" reloadable="false" />               #项目目录结构

Nginx配置:

server {
  listen 80;
  server_name [DomainName];
  location / {
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";

    proxy_pass http://127.0.0.1:7756;
  }
}

..........

  ...........

server {
  listen 443 ssl;
  server_name  [DomainName];
  ssl_certificate /usr/local/nginx/cert/applets.pem;
  ssl_certificate_key /usr/local/nginx/cert/applets.key;
  ssl_session_cache shared:SSL:1m;
  ssl_session_timeout 5m;

  ssl_ciphers HIGH:!aNULL:!MD5;
  ssl_prefer_server_ciphers on;
  location / {
    client_max_body_size 16m;
    client_body_buffer_size 128k;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Proto https;
    proxy_redirect off;
    proxy_connect_timeout 240;
    proxy_read_timeout 240;
    proxy_send_timeout 240;


    proxy_pass http://127.0.0.1:7756;
  }
}

猜你喜欢

转载自www.cnblogs.com/smlile-you-me/p/10554112.html
今日推荐