微信開發要求 必須用https 和 wss連接, 這里給出nginx反向代理配置, 自己使用一切正常,希望能幫助大家。域名一定要在微信開發后臺設置,不然連接不上, 域名要備案,不然 審核不通過。
nginx.conf 添加兩行。
`wss.conf 如下
upstream login_websocket
{
server 120
...:20013 weight
=1
;
server 120
...:20014 weight
=1
;
server 120
...:20012 weight
=1
;
}
upstream baseapp_websocket0
{
server 120
...:20015
;
}
upstream baseapp_websocket1
{
server 120
...:20016
;
}
upstream baseapp_websocket2
{
server 120
...:20017
;
}
upstream web
{
server www.**.cn:8081
;
}
server
{
listen 443
;
ssl on
;
ssl_certificate /usr/local/nginx/conf/server.crt
;
ssl_certificate_key /usr/local/nginx/conf/server.key
;
ssl_session_timeout 5m
;
ssl_session_cache shared:SSL:50m
;
ssl_protocols SSLv3 SSLv2 TLSv1 TLSv1.1 TLSv1.2
;
ssl_ciphers ALL:
!ADH:
!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP
;
underscores_in_headers on
;
location /login
{
proxy_pass http://login_websocket
;
proxy_http_version 1.1
;
proxy_set_header Upgrade
$http_upgrade;
proxy_set_header Connection
"Upgrade";
}
location /baseapp0
{proxy_pass http://baseapp_websocket0
;proxy_http_version 1.1
;proxy_set_header Upgrade
$http_upgrade;proxy_set_header Connection
"Upgrade";
}location /baseapp1
{proxy_pass http://baseapp_websocket1
;proxy_http_version 1.1
;proxy_set_header Upgrade
$http_upgrade;proxy_set_header Connection
"Upgrade";
}location /baseapp2
{proxy_pass http://baseapp_websocket2
;proxy_http_version 1.1
;proxy_set_header Upgrade
$http_upgrade;proxy_set_header Connection
"Upgrade";
}
location /
{
proxy_pass http://web
;
proxy_set_header X-Real-IP
$remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
add_header Access-Control-Allow-Origin *
;
}
地址:https://github.com/kbengine/kbengine/discussions/1354
新人創作打卡挑戰賽發博客就能抽獎!定制產品紅包拿不停!
總結
以上是生活随笔為你收集整理的kbengine 的 nginx反向代理https/wss 配置 支持kbe负载均衡的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。