Frequent disconnect when using nginx reverse proxy #2786
-
I set up nginx reverse proxy using linuxserver.io SWAG docker image for ComfyUI with basic authentication. But it kept disconnecting and reconnecting very frequently, about every few minutes or so. I haven't timed it yet. First glance at Firefox network debug shown that the reconnecting popup at the same time a websocket request was sent. I don't have any experience or knowledge in this subject, so does anybody have any idea? The config snippet for ComfyUI is as follows: server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name comfyui.*;
auth_basic "ComfyUI";
auth_basic_user_file /config/nginx/proxy-confs/conf/auth;
include /config/nginx/ssl.conf;
client_max_body_size 0;
location / {
include /config/nginx/proxy.conf;
include /config/nginx/resolver.conf;
set $upstream_app 192.168.100.20;
set $upstream_port 8188;
set $upstream_proto http;
proxy_pass $upstream_proto://$upstream_app:$upstream_port;
proxy_set_header Host $upstream_app:$upstream_port;
proxy_set_header X-Forwarded-For $host;
}
location /ws {
# include /config/nginx/proxy.conf;
# include /config/nginx/resolver.conf;
set $upstream_app 192.168.100.20;
set $upstream_port 8188;
set $upstream_proto http;
proxy_pass $upstream_proto://$upstream_app:$upstream_port;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $upstream_app:$upstream_port;
proxy_set_header X-Forwarded-Host $host;
proxy_read_timeout 36000s;
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Does the disconnect happen immediately after the call to /ws or a little bit after? server {
listen 8189 default_server;
server_name _;
location / {
proxy_pass http://comfyui:8188;
proxy_set_header Host $host;
}
location /ws {
proxy_pass http://comfyui:8188;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header Connection 'Upgrade';
proxy_set_header Upgrade $http_upgrade;
proxy_read_timeout 36000s;
} So I have two new questions:
|
Beta Was this translation helpful? Give feedback.
-
I found that you don't need a separate location block for /ws The key line here for me was I'm not sure if all of these lines are necessary, but this is working for me :-)
|
Beta Was this translation helpful? Give feedback.
-
After some trial and error with nginx tweaking and saved workflows not loading on click - This location block seems to be working for me. With no other location blocks. Just this one alone at the bottom of my tls server directive.
I'm posting this because this is the top google result for nginx reverse proxy configurations for ComfyUI and some of the included configs in this thread also had problems when loading workflows and such. |
Beta Was this translation helpful? Give feedback.
After some testing, it seems that it was a VPN fault. I had Cloudflare WARP running on the client machine (to unblock some medium.com sites). Without WARP activated, I don't see the disconnection anymore.