security 放行 websocket
时间: 2023-08-24 19:08:56 浏览: 116
要在nginx中放行websocket,你需要在nginx的配置文件中添加相应的配置。根据引用\[1\]和引用\[2\]的内容,你可以使用以下配置来放行websocket连接:
```
location /websocket/ {
proxy_pass http://127.0.0.1:8080; //你自己的转发目标地址
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 36000s; //设置超时时间
}
```
或者使用以下配置:
```
location /way/ {
proxy_pass http://localhost:8913;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_read_timeout 3600s; //设置超时时间
}
```
这样配置后,nginx会将websocket的请求转发到指定的目标地址,并且设置了相应的请求头信息和超时时间,从而实现了对websocket的放行。
#### 引用[.reference_title]
- *1* [学习记录680@springboot+vue+nginx+springsecurity环境下的websocket实战](https://blog.csdn.net/weixin_44663675/article/details/130245139)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* *3* [springzuul+spring security+https连接下使用websocket总结](https://blog.csdn.net/weixin_43900374/article/details/110917217)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文