nginx代理转发wss协议

0

首先有a端为浏览器,b端nginx,c端workerman.
现在的情况是a端有用https协议所以发起的ws连接必须为wss连接,所以b端配置了,ssl的支持,还有wss的转发,nginx的配置如下,
A:支持ssl


     server {
listen 443;
server_name localhost;
#
ssl on;
ssl_certificate D:\phpStudy\Apache\conf\ssl\server.crt;
ssl_certificate_key D:\phpStudy\Apache\conf\ssl\server.key;
#
ssl_session_timeout 5m;
#
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
#
root "D:/phpStudy/WWW";
location / {
index index.html index.htm index.php l.php;
autoindex off;
}
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}

下面支持wss转发的:


server {
listen 8020;
server_name 192.168.0.66;

ssl on;
ssl_certificate D:\phpStudy\Apache\conf\ssl\server.crt;
ssl_certificate_key D:\phpStudy\Apache\conf\ssl\server.key;
ssl_session_timeout 30m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

location / {
access_log off;
proxy_pass localhost:7272;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

# WebSocket support (nginx 1.4)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}

现在测试单机请求,到送到nginx的wss请求,可以及时的在c端控制台看到响应日志,但如果有另外一台电脑再发起一个wss连接,workerman就没有及时收到响应请求,然后a端浏览器onclose之后,b端的一下出来好多
下面是c端日志


--连接成功--2016-09-19 12:16:31-client:127.0.0.1:56532 gateway:127.0.0.1:7272  c
lient_id:7f00000108fc00000001 session

--消息处理client:127.0.0.1:56532 gateway:127.0.0.1:7272 client_id:7f00000108fc0
0000001 session:null onMessage:{"command":"login","username":"user1","wname":"wo
rk1"}

--消息处理client:127.0.0.1:56532 gateway:127.0.0.1:7272 client_id:7f00000108fc0
0000001 session:{"wname":"work1","username":"user1"} onMessage:{"command":"start
","wname":"work1"}

Notice: Undefined variable: clients_list in D:\workerman-chat-for-win-master\App
lications\Chat\Events.php on line 109

Warning: Invalid argument supplied for foreach() in D:\workerman-chat-for-win-ma
ster\Applications\Chat\Events.php on line 109
client:127.0.0.1:56532 gateway:127.0.0.1:7272 client_id:7f00000108fc00000001 on
Close:''

--连接成功--2016-09-19 12:27:09-client:127.0.0.1:56963 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000002 session

--消息处理client:127.0.0.1:56963 gateway:127.0.0.1:7272 client_id:7f00000108fc0
0000002 session:null onMessage:{"command":"login","username":"user1","wname":"wo
rk1"}
client:127.0.0.1:56963 gateway:127.0.0.1:7272 client_id:7f00000108fc00000002 on
Close:''

--连接成功--2016-09-19 12:33:16-client:127.0.0.1:57226 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000003 session

--消息处理client:127.0.0.1:57226 gateway:127.0.0.1:7272 client_id:7f00000108fc0
0000003 session:null onMessage:{"command":"login","username":"user1","wname":"wo
rk1"}
client:127.0.0.1:57226 gateway:127.0.0.1:7272 client_id:7f00000108fc00000003 on
Close:''

--连接成功--2016-09-19 12:34:51-client:127.0.0.1:57279 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000004 session

--连接成功--2016-09-19 12:34:54-client:127.0.0.1:57283 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000005 session

--连接成功--2016-09-19 12:34:54-client:127.0.0.1:57284 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000006 session

--连接成功--2016-09-19 12:34:54-client:127.0.0.1:57285 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000007 session

--连接成功--2016-09-19 12:34:54-client:127.0.0.1:57286 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000008 session

--连接成功--2016-09-19 12:34:54-client:127.0.0.1:57287 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000009 session

--消息处理client:127.0.0.1:57287 gateway:127.0.0.1:7272 client_id:7f00000108fc0
0000009 session:null onMessage:{"command":"login","username":"user2","wname":"wo
rk1"}
client:127.0.0.1:57279 gateway:127.0.0.1:7272 client_id:7f00000108fc00000004 on
Close:''
client:127.0.0.1:57283 gateway:127.0.0.1:7272 client_id:7f00000108fc00000005 on
Close:''
client:127.0.0.1:57284 gateway:127.0.0.1:7272 client_id:7f00000108fc00000006 on
Close:''
client:127.0.0.1:57285 gateway:127.0.0.1:7272 client_id:7f00000108fc00000007 on
Close:''
client:127.0.0.1:57286 gateway:127.0.0.1:7272 client_id:7f00000108fc00000008 on
Close:''
client:127.0.0.1:57287 gateway:127.0.0.1:7272 client_id:7f00000108fc00000009 on
Close:''

--连接成功--2016-09-19 12:36:02-client:127.0.0.1:57328 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc0000000a session

--消息处理client:127.0.0.1:57328 gateway:127.0.0.1:7272 client_id:7f00000108fc0
000000a session:null onMessage:{"command":"login","username":"user2","wname":"wo
rk1"}

--连接成功--2016-09-19 12:36:08-client:127.0.0.1:57334 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc0000000b session

--消息处理client:127.0.0.1:57334 gateway:127.0.0.1:7272 client_id:7f00000108fc0
000000b session:null onMessage:{"command":"login","username":"user1","wname":"wo
rk1"}
client:127.0.0.1:57334 gateway:127.0.0.1:7272 client_id:7f00000108fc0000000b on
Close:''
client:127.0.0.1:57328 gateway:127.0.0.1:7272 client_id:7f00000108fc0000000a on
Close:''

--连接成功--2016-09-19 12:37:53-client:127.0.0.1:57403 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc0000000c session

--连接成功--2016-09-19 12:38:20-client:127.0.0.1:57422 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc0000000d session

--消息处理client:127.0.0.1:57422 gateway:127.0.0.1:7272 client_id:7f00000108fc0
000000d session:null onMessage:{"command":"login","username":"user2","wname":"wo
rk1"}
client:127.0.0.1:57403 gateway:127.0.0.1:7272 client_id:7f00000108fc0000000c on
Close:''

--连接成功--2016-09-19 12:38:53-client:127.0.0.1:57439 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc0000000e session

--连接成功--2016-09-19 12:38:53-client:127.0.0.1:57441 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc0000000f session

--连接成功--2016-09-19 12:38:53-client:127.0.0.1:57443 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000010 session

--连接成功--2016-09-19 12:38:53-client:127.0.0.1:57445 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000011 session

--连接成功--2016-09-19 12:38:53-client:127.0.0.1:57449 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000012 session

--连接成功--2016-09-19 12:38:53-client:127.0.0.1:57451 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000013 session

--消息处理client:127.0.0.1:57451 gateway:127.0.0.1:7272 client_id:7f00000108fc0
0000013 session:null onMessage:{"command":"login","username":"user1","wname":"wo
rk1"}
client:127.0.0.1:57439 gateway:127.0.0.1:7272 client_id:7f00000108fc0000000e on
Close:''
client:127.0.0.1:57441 gateway:127.0.0.1:7272 client_id:7f00000108fc0000000f on
Close:''
client:127.0.0.1:57443 gateway:127.0.0.1:7272 client_id:7f00000108fc00000010 on
Close:''
client:127.0.0.1:57445 gateway:127.0.0.1:7272 client_id:7f00000108fc00000011 on
Close:''
client:127.0.0.1:57449 gateway:127.0.0.1:7272 client_id:7f00000108fc00000012 on
Close:''
client:127.0.0.1:57451 gateway:127.0.0.1:7272 client_id:7f00000108fc00000013 on
Close:''
client:127.0.0.1:57422 gateway:127.0.0.1:7272 client_id:7f00000108fc0000000d on
Close:''

--连接成功--2016-09-19 12:48:10-client:127.0.0.1:57781 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000014 session

--消息处理client:127.0.0.1:57781 gateway:127.0.0.1:7272 client_id:7f00000108fc0
0000014 session:null onMessage:{"command":"login","username":"user1","wname":"wo
rk1"}

--连接成功--2016-09-19 12:48:43-client:127.0.0.1:57811 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000015 session

--消息处理client:127.0.0.1:57811 gateway:127.0.0.1:7272 client_id:7f00000108fc0
0000015 session:null onMessage:{"command":"login","username":"user4","wname":"wo
rk1"}
client:127.0.0.1:57811 gateway:127.0.0.1:7272 client_id:7f00000108fc00000015 on
Close:''
client:127.0.0.1:57781 gateway:127.0.0.1:7272 client_id:7f00000108fc00000014 on
Close:''

--连接成功--2016-09-19 12:50:17-client:127.0.0.1:57890 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000016 session

--消息处理client:127.0.0.1:57890 gateway:127.0.0.1:7272 client_id:7f00000108fc0
0000016 session:null onMessage:{"command":"login","username":"user1","wname":"wo
rk1"}

--连接成功--2016-09-19 12:50:45-client:127.0.0.1:57909 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000017 session

--消息处理client:127.0.0.1:57909 gateway:127.0.0.1:7272 client_id:7f00000108fc0
0000017 session:null onMessage:{"command":"login","username":"user1","wname":"wo
rk1"}

--连接成功--2016-09-19 12:51:28-client:127.0.0.1:57937 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000018 session

--消息处理client:127.0.0.1:57937 gateway:127.0.0.1:7272 client_id:7f00000108fc0
0000018 session:null onMessage:{"command":"login","username":"user6","wname":"wo
rk1"}

--连接成功--2016-09-19 12:52:12-client:127.0.0.1:57965 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000019 session

--连接成功--2016-09-19 12:52:12-client:127.0.0.1:57966 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc0000001a session

--连接成功--2016-09-19 12:52:12-client:127.0.0.1:57967 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc0000001b session

--连接成功--2016-09-19 12:52:12-client:127.0.0.1:57968 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc0000001c session

--连接成功--2016-09-19 12:52:12-client:127.0.0.1:57969 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc0000001d session

--连接成功--2016-09-19 12:52:12-client:127.0.0.1:57972 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc0000001e session

--连接成功--2016-09-19 12:52:12-client:127.0.0.1:57973 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc0000001f session

--连接成功--2016-09-19 12:52:12-client:127.0.0.1:57974 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000020 session

--连接成功--2016-09-19 12:52:12-client:127.0.0.1:57975 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000021 session

--连接成功--2016-09-19 12:52:12-client:127.0.0.1:57976 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000022 session

--连接成功--2016-09-19 12:52:12-client:127.0.0.1:57977 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000023 session

--连接成功--2016-09-19 12:52:12-client:127.0.0.1:57978 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000024 session

--连接成功--2016-09-19 12:52:13-client:127.0.0.1:57979 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000025 session

--连接成功--2016-09-19 12:52:13-client:127.0.0.1:57980 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000026 session

--连接成功--2016-09-19 12:52:13-client:127.0.0.1:57981 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000027 session

--连接成功--2016-09-19 12:52:13-client:127.0.0.1:57982 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000028 session

--连接成功--2016-09-19 12:52:13-client:127.0.0.1:57983 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc00000029 session

--连接成功--2016-09-19 12:52:13-client:127.0.0.1:57984 gateway:127.0.0.1:7272 c
lient_id:7f00000108fc0000002a session

--消息处理client:127.0.0.1:57984 gateway:127.0.0.1:7272 client_id:7f00000108fc0
000002a session:null onMessage:{"command":"login","username":"user3","wname":"wo
rk1"}
client:127.0.0.1:57965 gateway:127.0.0.1:7272 client_id:7f00000108fc00000019 on
Close:''
client:127.0.0.1:57966 gateway:127.0.0.1:7272 client_id:7f00000108fc0000001a on
Close:''
client:127.0.0.1:57967 gateway:127.0.0.1:7272 client_id:7f00000108fc0000001b on
Close:''
client:127.0.0.1:57968 gateway:127.0.0.1:7272 client_id:7f00000108fc0000001c on
Close:''
client:127.0.0.1:57969 gateway:127.0.0.1:7272 client_id:7f00000108fc0000001d on
Close:''
client:127.0.0.1:57972 gateway:127.0.0.1:7272 client_id:7f00000108fc0000001e on
Close:''
client:127.0.0.1:57973 gateway:127.0.0.1:7272 client_id:7f00000108fc0000001f on
Close:''
client:127.0.0.1:57974 gateway:127.0.0.1:7272 client_id:7f00000108fc00000020 on
Close:''
client:127.0.0.1:57975 gateway:127.0.0.1:7272 client_id:7f00000108fc00000021 on
Close:''
client:127.0.0.1:57976 gateway:127.0.0.1:7272 client_id:7f00000108fc00000022 on
Close:''
client:127.0.0.1:57977 gateway:127.0.0.1:7272 client_id:7f00000108fc00000023 on
Close:''
client:127.0.0.1:57978 gateway:127.0.0.1:7272 client_id:7f00000108fc00000024 on
Close:''
client:127.0.0.1:57979 gateway:127.0.0.1:7272 client_id:7f00000108fc00000025 on
Close:''
client:127.0.0.1:57980 gateway:127.0.0.1:7272 client_id:7f00000108fc00000026 on
Close:''
client:127.0.0.1:57981 gateway:127.0.0.1:7272 client_id:7f00000108fc00000027 on
Close:''
client:127.0.0.1:57982 gateway:127.0.0.1:7272 client_id:7f00000108fc00000028 on
Close:''
client:127.0.0.1:57983 gateway:127.0.0.1:7272 client_id:7f00000108fc00000029 on
Close:''
client:127.0.0.1:57984 gateway:127.0.0.1:7272 client_id:7f00000108fc0000002a on
Close:''
client:127.0.0.1:57890 gateway:127.0.0.1:7272 client_id:7f00000108fc00000016 on
Close:''
client:127.0.0.1:57909 gateway:127.0.0.1:7272 client_id:7f00000108fc00000017 on
Close:''
client:127.0.0.1:57937 gateway:127.0.0.1:7272 client_id:7f00000108fc00000018 on
Close:''
已邀请:

要回复问题请先登录注册