我正试图与NGINX公司建立"wss“关系。"ws",没有SSL,工作正常。
(我将实际的项目域名替换为"test.thruway.local")
这是nginx配置:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream thruway_websocket {
server 127.0.0.1:9090;
}
server {
listen 9190;
listen [::]:9190;
server_name test.thruway.local;
access_log /var/log/nginx/test.thruway.access_log;
error_log /var/log/nginx/test.thruway.error_log;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# tried both "https://" and "http://"
proxy_pass https://thruway_websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_ssl_certificate /etc/letsencrypt/live/test.thruway.local/fullchain.pem;
proxy_ssl_certificate_key /etc/letsencrypt/live/test.thruway.local/privkey.pem;
}
# not sure if this is needed here. Tried with and without.
ssl_certificate /etc/letsencrypt/live/test.thruway.local/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/test.thruway.local/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}端口是开放的,请求似乎可以通过:
# ufw status
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
Nginx Full ALLOW Anywhere
9190/tcp ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
Nginx Full (v6) ALLOW Anywhere (v6)
9190/tcp (v6) ALLOW Anywhere (v6) 我使用AutobahnJS向9190端口发出请求:
new autobahn.Connection( {
url: 'wss://test.thruway.local:9190',
realm: 'test'
} );nginx访问日志输入了一个条目,告诉我它显然是连接在一起的.但是日志本身是一堆乱七八糟的ASCII代码,NGINX返回错误400。
像这样的东西(IP改变了):
111.111.11.111 - - [08/Sep/2021:12:57:24 +0200] "\x10\x04\x01\x02\x00\x01\x00\x00\xF0\x03\x02.\xA0\x90\xD1\x10\xA5\xF0\x8C\xF2 (... etc)" 400 182 "-" "-"一切都很好,只使用ws而不是wss。我已经尝试过几次调整,通过任何我能找到的材料--似乎什么都不管用。
不管我怎么尝试,我总能得到:
“火狐无法在wss://test.trway.local:9190/上建立到服务器的连接。
有人知道我能做些什么吗?我感谢任何想法,我没有办法去尝试了。
发布于 2021-09-09 08:15:40
我想我知道这里缺少的是什么:
server {
ssl on;
}我仍然在测试更改,但是这样的话,日志就不再是乱七八糟的了,而且连接似乎很好。
https://stackoverflow.com/questions/69102360
复制相似问题