我正在嘗試配置我的 nginx 服務器,以便我可以wss用于我的域:
server {
listen [::]:80;
listen 80;
server_name example.com www.example.com;
location /.well-known/acme-challenge {
allow all;
root /var/www/certbot;
}
# redirect http to https www
return 301 https://www.example.com$request_uri;
}
server {
listen [::]:443 ssl http2;
listen 443 ssl http2;
server_name example.com;
# SSL code
ssl_certificate /etc/nginx/ssl/live/example.com/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/live/example.com/privkey.pem;
root /var/www/html;
location / {
index index.html;
}
return 301 https://www.example.com$request_uri;
}
server {
listen [::]:443 ssl http2;
listen 443 ssl http2;
server_name www.example.com;
# SSL code
ssl_certificate /etc/nginx/ssl/live/example.com/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/live/example.com/privkey.pem;
root /var/www/html;
location / {
index index.html;
}
location /ph/ {
proxy_pass http://xxx.xxx.xxx.xx:3000/;
}
# websocket
location /ph/socket/ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass https://ws-backend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
upstream ws-backend {
server xxx.xxx.xxx.xx:3000;
}
但我收到此錯誤:
web_1 | 2022/04/18 00:40:53 [錯誤] 24#24: *11 SSL_do_handshake() 失敗(SSL:錯誤:1408F10B:SSL 例程:ssl3_get_record:錯誤的版本號)同時 SSL 與上游握手,客戶端:42.xxx .xxx.xxx,服務器:www.example.com,請求:“GET /ph/socket//websocket?vsn=2.0.0 HTTP/1.1”,上游:“https://xxx.xxx.xxx.xx: 3000/ph/socket//websocket?vsn=2.0.0”,主機:“www.example.com”
我該如何解決這個問題?
uj5u.com熱心網友回復:
根據這個答案,考慮改變你的
proxy_pass https :// ws -backend;
到
proxy_pass http ://ws-backend;
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/461676.html
上一篇:Nginx-Uwsgi-Dockerconnect()tounix:/usr/src/app/uwsgi.sockfailed(2:Nosuchfileordirectory)
