最近工作中需要给各厂商配置域名代理,记录一下出现的问题。
# 配置WebSocket,支持wss协议
>wss 协议实际是 websocket+SSL,就是在 websocket 协议上加入 SSL 层,类似 https(http+SSL)。
错误截图如下,发现他们用的是 wss 协议,而我们代理用的是 http,所以需要给他们单独配置。

配置如下:
```
location ^~ /test/test {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_pass https://test.service;
}
```
# 获取不到真实IP
当使用 `ServletUtil.getClientIP()` 获取不到真实的 IP 时,一般是由于配置问题。
加上一下配置:
```
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
```

Nginx代理配置问题记录