配置websocket wss连接
servern{n listen 80;n listen 443 ssl http2;n server_name chat.***.cn; //二级域名n index index.php index.h
servern{n listen 80;n listen 443 ssl http2;n server_name chat.***.cn; //二级域名n index index.php index.html index.htm default.php default.htm default.html;n root /home/wwwroot/chat.**.cn; //项目地址n n #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则n #error_page 404/404.html;n ssl_certificate /etc/letsencrypt/live/chat.***.cn/fullchain.pem; //ssl地址n ssl_certificate_key /etc/letsencrypt/live/chat.***.cn/privkey.pem;n ssl_protocols TLSv1 TLSv1.1 TLSv1.2;n ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;n ssl_prefer_server_ciphers on;n ssl_session_cache shared:SSL:10m;n ssl_session_timeout 10m;n error_page 497 https://$host$request_uri;nn #SSL-ENDn n #ERROR-PAGE-START 错误页配置,可以注释、删除或修改n error_page 404 /404.html;n error_page 502 /502.html;n #ERROR-PAGE-ENDn n #PHP-INFO-START PHP引用配置,可以注释或修改n include enable-php-72.conf;n #PHP-INFO-ENDn n #REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效n include /www/server/panel/vhost/rewrite/chat.***.cn.conf;n #REWRITE-ENDn n #禁止访问的文件或目录n location ~ ^/(.user.ini|.htaccess|.git|.svn|.project|LICENSE|README.md)n {n return 404;n }n n #一键申请SSL证书验证目录相关设置n location ~ .well-known{n allow all;n }n n location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$n {n expires 30d;n error_log off;n access_log off;n }n n location ~ .*.(js|css)?$n {n expires 12h;n error_log off;n access_log off; n }n ntlocation /wss {n proxy_pass http://chat.***.cn:8282; #代理到上面的地址去,格式:http://域名:端口号,n proxy_http_version 1.1;n proxy_set_header Upgrade $http_upgrade;n proxy_set_header Connection "Upgrade";n proxy_connect_timeout 1s; #配置点1,代理连接超时时长n proxy_read_timeout 60000s; #配置点2,代理读取超时时长n proxy_send_timeout 60000s; #配置点3,代理发送超时时长n }n}