В настоящее время я создаю чат на своем сайте и столкнулся с WSS. Я пробовал разные способы заставить эту штуку работать на моем сервере, но ни один из них не был успешным.
WS отлично работает на другом домене без SSL, но когда дело доходит до стабильного браузера WSS, получите 301 "Перемещено навсегда"статус запроса.
Запрос клиента:
window.onload = function () {
var socket = new WebSocket("wss://domain.su/ws");
var status = document.querySelector("#status");
socket.onopen = function () {
status.innerHTML = "established";
}
socket.onclose = function () {
status.innerHTML = "dropped";
}
}
Конфигурация NGINX сайта:
server {
listen 192.168.0.1:80;
server_name domain.info www.domain.info;
return 301 https://domain.info$request_uri;
}
server {
listen 192.168.0.1:80;
server_name domain.su www.domain.su;
return 301 https://domain.su$request_uri;
}
server {
listen 192.168.0.1:443 ssl;
server_name www.domain.info;
return 301 https://domain.info$request_uri;
ssl_certificate /home/admin/conf/web/ssl.domain.info.crt;
ssl_certificate_key /home/admin/conf/web/ssl.domain.info.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
}
server {
listen 192.168.0.1:443 ssl;
server_name www.domain.su;
return 301 https://domain.su$request_uri;
ssl_certificate /home/admin/conf/web/ssl.domain.info.crt;
ssl_certificate_key /home/admin/conf/web/ssl.domain.info.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
}
server {
listen 192.168.0.1:80;
listen 192.168.0.1:443 ssl;
ssl_certificate /home/admin/conf/web/ssl.domain.info.crt;
ssl_certificate_key /home/admin/conf/web/ssl.domain.info.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
server_name domain.info domain.su;
root /home/admin/web/domain.info/public_html;
index index.php index.html index.htm;
access_log /var/log/nginx/domains/domain.info.log combined;
access_log /var/log/nginx/domains/domain.info.bytes bytes;
error_log /var/log/nginx/domains/domain.info.error.log error;
location /ws {
proxy_pass http://domain.info;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $http_host;
proxy_set_header Proxy "";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 86400;
proxy_redirect off;
}
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php;
}
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
expires max;
}
location ~ [^/]\.php(/|$) {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass 127.0.0.1:9003;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
}
error_page 403 /error/404.html;
error_page 404 /error/404.html;
error_page 500 502 503 504 /error/50x.html;
location /error/ {
alias /home/admin/web/domain.info/document_errors/;
}
location ~* "/\.(htaccess|htpasswd)$" {
deny all;
return 404;
}
location /vstats/ {
alias /home/admin/web/domain.info/stats/;
include /home/admin/conf/web/domain.info.auth*;
}
include /etc/nginx/conf.d/phpmyadmin.inc*;
include /etc/nginx/conf.d/phppgadmin.inc*;
include /etc/nginx/conf.d/webmail.inc*;
include /home/admin/conf/web/nginx.domain.info.conf*;
}
~
~
~
~
Есть идеи, что может быть не так с config?