Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
themeRDark
        location /wss {
            proxy_set_header Host $host;
if ($http_connection !~* "upgrade") {
                proxy_pass https://localhost:8443return 403;
            proxy_http_version 1.1;}
            proxy_set_header Upgrade if ($http_upgrade; !~* "websocket") {
            proxy_set_header Connection "upgrade"    return 403;
            }
            proxy_readset_timeoutheader Host 86400$host;
            }

4. Перезапустите nginx

5. Для установки Websocket соединения из браузера используйте URL

Code Block
themeRDark
wssproxy_pass https://login:password@wcs.yourdomain.com:443/wss
Code Block
themeRDark
titleПолный файл настройки nginx
collapsetrue
http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
          localhost:8443;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_read_timeout 86400;
        }

4. Перезапустите nginx

5. Для установки Websocket соединения из браузера используйте URL

Code Block
themeRDark
wss://login:password@wcs.yourdomain.com:443/wss
Code Block
themeRDark
titleПолный файл настройки nginx
collapsetrue
http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    '"$http_user_agent" "$http_x_forwarded_for"';

auth_basic "Restricted Area";
    access_log  /var/logauth_basic_user_file /etc/nginx/access.loghtpasswd;
    main;

     sendfileinclude /etc/nginx/conf.d/*.conf;
    
    server {
		listen 443  on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048ssl;
		ssl_certificate /etc/pki/tls/yourdomain/yourdomain.crt;
		ssl_certificate_key /etc/pki/tls/yourdomain/yourdomain.key;
		server_name wcs.yourdomain.com;
		server_tokens off;
		client_max_body_size 500m;
		proxy_read_timeout 10m;

    include    include /etc/nginx/default.d/*.conf;

        /etc/nginx/mime.types;location / {
    default_type    }

    application/octet-stream;

    auth_basic "Restricted Area";location /wss {
    auth_basic_user_file /etc/nginx/.htpasswd;
    
   if include /etc/nginx/conf.d/*.conf;
    ($http_connection !~* "upgrade") {
    server {
		listen 443 ssl;
		ssl_certificate /etc/pki/tls/yourdomain/yourdomain.crt;
		ssl_certificate_key /etc/pki/tls/yourdomain/yourdomain.key;
		server_name wcs.yourdomain.com;
		server_tokens off;
		client_max_body_size 500m;
		proxy_read_timeout 10m;
          return 403;
            }
        include /etc/nginx/default.d/*.conf;

   if ($http_upgrade !~* "websocket") {
   location / {
        }

   return 403;
    location /wss {
      }
           proxy proxy_set_header Host $host;
            proxy_pass https://localhost:8443;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_read_timeout 86400;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
        
    }
}

...