配置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}









