map $http_upgrade $connection_upgrade { default upgrade; '' close; } map $http_upgrade $upgrade_request { default 1; '' 0; } server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; location / { error_page 418 = @websocket; if ($upgrade_request = 1) { return 418; } try_files $uri $uri/ /index.html; } location @websocket { proxy_pass http://broker:9001; proxy_http_version 1.1; proxy_read_timeout 1d; proxy_send_timeout 1d; proxy_set_header Host $host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; } }