Chinaunix首页 | 论坛 | 博客
  • 博客访问: 278168
  • 博文数量: 73
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 452
  • 用 户 组: 普通用户
  • 注册时间: 2014-09-22 17:07
个人简介

心态决定命运

文章分类

全部博文(73)

文章存档

2017年(21)

2016年(27)

2015年(21)

2014年(4)

我的朋友

分类: 系统运维

2017-05-31 17:48:00

    今天配置nginx反向代理,按照官方提供的方法配置后
配置:

点击(此处)折叠或打开

  1. http {
  2.     map $http_upgrade $connection_upgrade {
  3.         default upgrade;
  4.         '' close;
  5.     }

  6.     server {
  7.         ...

  8.         location /websocket/ {
  9.             proxy_pass http://backend;
  10.             proxy_http_version 1.1;
  11.             proxy_set_header Upgrade $http_upgrade;
  12.             proxy_set_header Connection $connection_upgrade;
  13.         }
  14.     }
出现 403错误

点击(此处)折叠或打开

  1. WebSocket connection to 'ws://ip/websocket/aa' failed: Error during WebSocket handshake:Unexpected response code:403

解决方法:
添加以下命令:

点击(此处)折叠或打开

  1. # Pass the csrf token (see https://de.wikipedia.org/wiki/Cross-Site-Request-Forgery)
  2.     # Default in Spring Boot and required. Without it nginx suppresses the value
  3.     proxy_pass_header X-XSRF-TOKEN;

  4.     # Set origin to the real instance, otherwise a of Spring security check will fail
  5.     # Same value as defined in proxy_pass
  6.     proxy_set_header Origin ""

参考:
 
  https://my.oschina.net/wrs/blog/727313
阅读(1243) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~