springboot nginx 支持https反向代理websocket

nginx反向代理websocket

# webSocket wss 加密链接
location /ws {
      proxy_pass http://127.0.0.1:2222/ws;
      
      proxy_set_header Host $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_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
}

 springboot application.yml配置

server:
  tomcat:
    remote-ip-header: X-Forwarded-For
    port-header: X-Forwarded-Port
    protocol-header: X-Forwarded-Proto
    protocol-header-https-value: https

 

posted @ 2023-03-08 03:46  sevennight  阅读(243)  评论(0编辑  收藏  举报