当前位置: 首页 > 工具软件 > Jeecg-Boot > 使用案例 >

【配置】Nginx 配置 ws wss jeecg-boot websocket

傅增
2023-12-01

【配置】Nginx 配置 ws wss jeecg-boot websocket

    # wss 配置
     location ^~ /jeecg-boot/  {
    			proxy_pass http://127.0.0.1:8080/jeecg-boot/;
    	
    			proxy_set_header X-Real-IP $remote_addr;
    		
    			proxy_set_header Host $host;
    			proxy_set_header X-NginX-Proxy true;
    			proxy_http_version 1.1;
    			proxy_set_header Upgrade $http_upgrade;
    			proxy_set_header Connection "Upgrade";
    			proxy_connect_timeout 600s;
    			proxy_read_timeout 600;
    			proxy_send_timeout 600s;
    			
    			
    			proxy_set_header X-Forwarded-Scheme  $scheme;
    			proxy_redirect    off;   
    			set $my_proxy_add_x_forwarded_for $proxy_add_x_forwarded_for;
        	if ($proxy_add_x_forwarded_for ~* "127.0.0.1"){
        		  set $my_proxy_add_x_forwarded_for $remote_addr;
        	}
        		
        	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        		
    }

      #配置wss开始-----/ws /DataReal/ 路径后还有参数配置如下:----------
       location ^~ /ws/DataReal/  {
			proxy_pass http://192.168.2.3:8080/ws/DataReal/;
	
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header Host $host;
			proxy_set_header X-NginX-Proxy true;
			proxy_http_version 1.1;
			proxy_set_header Upgrade $http_upgrade;
			proxy_set_header Connection "Upgrade";
			proxy_connect_timeout 600s;
			proxy_read_timeout 600;
			proxy_send_timeout 600s;
       }
       #配置wss结束------------------------------------------

      #配置wss开始---/ws /live/ 路径后没有参数配置如下:----------
       location /ws/live {
			proxy_pass http://192.168.2.3:8080/ws/live;
	
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header Host $host;
			proxy_set_header X-NginX-Proxy true;
			proxy_http_version 1.1;
			proxy_set_header Upgrade $http_upgrade;
			proxy_set_header Connection "Upgrade";
			proxy_connect_timeout 600s;
			proxy_read_timeout 600;
			proxy_send_timeout 600s;
	  }
       #配置wss结束------------------------------------------

 类似资料: