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   proxy_readset_timeoutheader Host 86400$host;
            }

4. Restart nginx

5. Use the following Websocket URL to connect from browser

Code Block
themeRDark
wssproxy_pass https://login:password@wcs.yourdomain.com:443/wss
Code Block
themeRDark
titleFull nginx configuration file
collapsetrue
http {
localhost:8443;
            proxy_http_version 1.1;
      log_format  main  '$remote_addr - $remote_user [$time_local] "$request" 'proxy_set_header Upgrade $http_upgrade;
            proxy_set_header          '$status $body_bytes_sent "$http_referer" 'Connection "upgrade";
                      '"$http_user_agent" "$http_x_forwarded_for"';

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

    sendfile            on    }

4. Restart nginx

5. Use the following Websocket URL to connect from browser

Code Block
themeRDark
wss://login:password@wcs.yourdomain.com:443/wss
Code Block
themeRDark
titleFull nginx configuration file
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;
    tcp_nopushtypes_hash_max_size 2048;

    include             on/etc/nginx/mime.types;
    tcpdefault_nodelaytype         onapplication/octet-stream;

    keepaliveauth_timeoutbasic "Restricted  65Area";
    typesauth_hashbasic_maxuser_size 2048;
file /etc/nginx/.htpasswd;
    
    include /etc/nginx/conf.d/*.conf;
    
    server {
		listen 443 ssl;
		ssl_certificate /etc/pki/tls/yourdomain/yourdomain.crt;
		ssl_certificate_key /etc/nginx/mime.types;
    default_type        application/octet-stream;

    auth_basic "Restricted Area";
    auth_basic_user_file /etc/nginx/.htpasswd;pki/tls/yourdomain/yourdomain.key;
		server_name wcs.yourdomain.com;
		server_tokens off;
		client_max_body_size 500m;
		proxy_read_timeout 10m;

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

    
    location 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;

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

        }

        location /wss {
            if ($http_connection !~* "upgrade") {
                return 403;
            }
            if  location /($http_upgrade !~* "websocket") {
            }

    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 {
        }
        
    }
}

...