September 1, 20232 yr 使用linuxserver/swag版本的SWAG进行反向代理,代理各个容器均正常,想要代理UNRAID面板的时候出现了问题,在配置文件中直接指向UNRAID的内网IP,能正常打开UNRAID面板,但是磁盘信息、CPU占用等均无法显示。找了一些资料,貌似是ws通信的问题,网上找了些教程都是NPM版本的解决方法,不知道该如何应用到SWAG上,请大神指教。 PS:在使用SWAG前我也尝试使用NPM,但经常会出现bad gateway错误,遂放弃。
September 1, 20232 yr Solution 不管是 SWAG 也好,NPM(Nginx Proxy Manager)也好,反代 Unraid 如果没有在反向代理配置中设置 proxy_set_header Host $http_host 这一参数,那么你会发现访问 Unraid 后会不带端口号进行跳转;另外由于 websocket 的问题,也会导致一些动态信息无法获取,就比如题主这里提到的磁盘信息、CPU占用等法显示。以上问题除了 Unraid 之外,还存在于可道云、Nextcloud 等应用反代中,因此都可以通过以下方式进行解决。 解决办法如下: SWAG: server { listen 443 ssl; #listen [::]:443 ssl; # 这里替换成设置的域名 server_name unraid.*; include /config/nginx/ssl.conf; client_max_body_size 0; # enable for ldap auth, fill in ldap details in ldap.conf #include /config/nginx/ldap.conf; # enable for Authelia #include /config/nginx/authelia-server.conf; location / { #include /config/nginx/proxy.conf; include /config/nginx/resolver.conf; # 填写服务的ip地址 set $upstream_app 192.168.5.19; # 填写对应服务的端口 set $upstream_port 8096; set $upstream_proto http; proxy_pass $upstream_proto://$upstream_app:$upstream_port; client_body_buffer_size 128k; # 禁用 buffer proxy_buffering off; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503; proxy_buffers 64 256k; proxy_connect_timeout 240; proxy_headers_hash_bucket_size 128; proxy_headers_hash_max_size 1024; proxy_http_version 1.1; proxy_read_timeout 240; proxy_redirect http:// $scheme://; send_timeout 5m; # 缓存和 Cookie proxy_cache_bypass $cookie_session; proxy_no_cache $cookie_session; #proxy_cookie_path / "/; Secure"; # enable at your own risk, may break certain apps # 请求头 proxy_set_header Connection $connection_upgrade; proxy_set_header Early-Data $ssl_early_data; proxy_set_header Host $http_host; proxy_set_header Upgrade $http_upgrade; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $http_host; proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-Ssl on; proxy_set_header X-Real-IP $remote_addr; } } NPM(以下参数的用法参考这里): client_max_body_size 0; proxy_max_temp_file_size 0; proxy_buffering off; proxy_request_buffering off; location / { proxy_pass $forward_scheme://$server:$port; proxy_set_header Host $http_host; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Host $http_host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Port $port; proxy_set_header X-Forwarded-Method $request_method; proxy_set_header X-Forwarded-Ssl on; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Original-URL $scheme://$http_host$request_uri; proxy_set_header X-Forwarded-Uri $request_uri; } Edited September 1, 20232 yr by JackieWu
September 1, 20232 yr 4 hours ago, worthless-agate6824 said: 使用linuxserver/swag版本的SWAG进行反向代理,代理各个容器均正常,想要代理UNRAID面板的时候出现了问题,在配置文件中直接指向UNRAID的内网IP,能正常打开UNRAID面板,但是磁盘信息、CPU占用等均无法显示。找了一些资料,貌似是ws通信的问题,网上找了些教程都是NPM版本的解决方法,不知道该如何应用到SWAG上,请大神指教。 PS:在使用SWAG前我也尝试使用NPM,但经常会出现bad gateway错误,遂放弃。 同使用linuxserver/swag版本的SWAG进行反向代理,没发觉任何问题。 Edited September 1, 20232 yr by atim520
September 1, 20232 yr Author 47 minutes ago, JackieWu said: 不管是 SWAG 也好,NPM(Nginx Proxy Manager)也好,反代 Unraid 如果没有在反向代理配置中设置 proxy_set_header Host $http_host 这一参数,那么你会发现访问 Unraid 后会不带端口号进行跳转;另外由于 websocket 的问题,也会导致一些动态信息无法获取,就比如题主这里提到的磁盘信息、CPU占用等法显示。以上问题除了 Unraid 之外,还存在于可道云、Nextcloud 等应用反代中,因此都可以通过以下方式进行解决。 解决办法如下: SWAG: server { listen 443 ssl; #listen [::]:443 ssl; # 这里替换成设置的域名 server_name unraid.*; include /config/nginx/ssl.conf; client_max_body_size 0; # enable for ldap auth, fill in ldap details in ldap.conf #include /config/nginx/ldap.conf; # enable for Authelia #include /config/nginx/authelia-server.conf; location / { #include /config/nginx/proxy.conf; include /config/nginx/resolver.conf; # 填写服务的ip地址 set $upstream_app 192.168.5.19; # 填写对应服务的端口 set $upstream_port 8096; set $upstream_proto http; proxy_pass $upstream_proto://$upstream_app:$upstream_port; client_body_buffer_size 128k; # 禁用 buffer proxy_buffering off; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503; proxy_buffers 64 256k; proxy_connect_timeout 240; proxy_headers_hash_bucket_size 128; proxy_headers_hash_max_size 1024; proxy_http_version 1.1; proxy_read_timeout 240; proxy_redirect http:// $scheme://; send_timeout 5m; # 缓存和 Cookie proxy_cache_bypass $cookie_session; proxy_no_cache $cookie_session; #proxy_cookie_path / "/; Secure"; # enable at your own risk, may break certain apps # 请求头 proxy_set_header Connection $connection_upgrade; proxy_set_header Early-Data $ssl_early_data; proxy_set_header Host $http_host; proxy_set_header Upgrade $http_upgrade; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $http_host; proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-Ssl on; proxy_set_header X-Real-IP $remote_addr; } } NPM(以下参数的用法参考这里): client_max_body_size 0; proxy_max_temp_file_size 0; proxy_buffering off; proxy_request_buffering off; location / { proxy_pass $forward_scheme://$server:$port; proxy_set_header Host $http_host; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Host $http_host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Port $port; proxy_set_header X-Forwarded-Method $request_method; proxy_set_header X-Forwarded-Ssl on; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Original-URL $scheme://$http_host$request_uri; proxy_set_header X-Forwarded-Uri $request_uri; } 感谢大神回复,我复制了您的swag代码,替换到我自己的unraid.subdomain.conf文件内,修改了我的内网IP和端口,重启swag后并没有解决问题,磁盘信息和CPU信息依然没有显示。请问是否有哪里操作不当?
September 1, 20232 yr Author 32 minutes ago, atim520 said: 同使用linuxserver/swag版本的SWAG进行反向代理,没发觉任何问题。 可否分享一下配置文件代码?感谢。
September 1, 20232 yr 4 minutes ago, worthless-agate6824 said: 感谢大神回复,我复制了您的swag代码,替换到我自己的unraid.subdomain.conf文件内,修改了我的内网IP和端口,重启swag后并没有解决问题,磁盘信息和CPU信息依然没有显示。请问是否有哪里操作不当? 情况浏览器缓存,或者使用浏览器隐身模式再试试
September 1, 20232 yr 12 minutes ago, worthless-agate6824 said: 可否分享一下配置文件代码?感谢。 ## Version 2023/05/31 # make sure that your dns has a cname set for unraid server { listen 443 ssl http2; #listen [::]:443 ssl; server_name unraid.*; include /config/nginx/ssl.conf; client_max_body_size 0; # enable for ldap auth (requires ldap-location.conf in the location block) #include /config/nginx/ldap-server.conf; # enable for Authelia (requires authelia-location.conf in the location block) #include /config/nginx/authelia-server.conf; location / { # enable the next two lines for http auth #auth_basic "Restricted"; #auth_basic_user_file /config/nginx/.htpasswd; # enable for ldap auth (requires ldap-server.conf in the server block) #include /config/nginx/ldap-location.conf; # enable for Authelia (requires authelia-server.conf in the server block) #include /config/nginx/authelia-location.conf; include /config/nginx/proxy.conf; include /config/nginx/resolver.conf; set $upstream_app 192.168.3.4; set $upstream_port 80; set $upstream_proto http; proxy_pass $upstream_proto://$upstream_app:$upstream_port; } }
September 1, 20232 yr Author 19 minutes ago, JackieWu said: 情况浏览器缓存,或者使用浏览器隐身模式再试试 清空缓存后,问题依旧😂 我也尝试过在proxy.conf文件中修改 proxy_set_header 请求头,但依然没有解决问题,劳烦大神再帮我想想,还有什么可能性? 我的unraid调用的是默认的80端口,这应该不会有什么影响吧? 另外,我使用CF进行DNS解析,因为运营商封锁公网443端口,我用CF规则将swag外网网址端口强制跳转到其他端口,这是否会造成影响?
September 1, 20232 yr Author 16 minutes ago, atim520 said: ## Version 2023/05/31 # make sure that your dns has a cname set for unraid server { listen 443 ssl http2; #listen [::]:443 ssl; server_name unraid.*; include /config/nginx/ssl.conf; client_max_body_size 0; # enable for ldap auth (requires ldap-location.conf in the location block) #include /config/nginx/ldap-server.conf; # enable for Authelia (requires authelia-location.conf in the location block) #include /config/nginx/authelia-server.conf; location / { # enable the next two lines for http auth #auth_basic "Restricted"; #auth_basic_user_file /config/nginx/.htpasswd; # enable for ldap auth (requires ldap-server.conf in the server block) #include /config/nginx/ldap-location.conf; # enable for Authelia (requires authelia-server.conf in the server block) #include /config/nginx/authelia-location.conf; include /config/nginx/proxy.conf; include /config/nginx/resolver.conf; set $upstream_app 192.168.3.4; set $upstream_port 80; set $upstream_proto http; proxy_pass $upstream_proto://$upstream_app:$upstream_port; } } 感谢您的代码,我试了一下,还是不能显示数据
September 1, 20232 yr 2 minutes ago, worthless-agate6824 said: 我用CF规则将swag外网网址端口强制跳转到其他端口,这是否会造成影响? 会,你用了 Origin Rules 是吧,先不要这么用,你先去掉 CF 这一层,只做解析再试试。
September 1, 20232 yr 10 minutes ago, worthless-agate6824 said: 感谢您的代码,我试了一下,还是不能显示数据 估计你都做了,还是提醒下: 1.unraid设置里面 ssl/tls 选择关闭(否); 2.swag的proxy.conf配置文件不用该,除非你知道你在干什么; 3.处理问题的思路是从简单到复杂,从最核心的地方一步一步往外面套,比如先把防火墙关了,看看能不能正常使用,再开启防火墙。
September 1, 20232 yr Author 18 minutes ago, JackieWu said: 会,你用了 Origin Rules 是吧,先不要这么用,你先去掉 CF 这一层,只做解析再试试。 我尝试关闭了CF的规则,使用网址+端口号登录,但发现所有容器,包括unraid界面均无法显示,主域名的swag界面同样不显示😅 重新启用规则就恢复正常了,当然unraid数据依然无法正常显示。
September 1, 20232 yr Author 9 minutes ago, atim520 said: 估计你都做了,还是提醒下: 1.unraid设置里面 ssl/tls 选择关闭(否); 2.swag的proxy.conf配置文件不用该,除非你知道你在干什么; 3.处理问题的思路是从简单到复杂,从最核心的地方一步一步往外面套,比如先把防火墙关了,看看能不能正常使用,再开启防火墙。 虽然我还是没找到问题所在,但依然非常感谢您的提醒😊
September 1, 20232 yr 1 minute ago, worthless-agate6824 said: 我尝试关闭了CF的规则,使用网址+端口号登录,但发现所有容器,包括unraid界面均无法显示,主域名的swag界面同样不显示😅 重新启用规则就恢复正常了,当然unraid数据依然无法正常显示。 SWAG 容器日志有什么报错没
September 1, 20232 yr Author 1 minute ago, JackieWu said: SWAG 容器日志有什么报错没 日志正常,没有报错提醒。 Quote dns validation via cloudflare plugin is selected Certificate exists; parameters unchanged; starting nginx The cert does not expire within the next day. Letting the cron script handle the renewal attempts overnight (2:08am). **** installing docker and docker compose **** **** Applying the SWAG dashboard mod... **** **** docker and docker-compose already installed, skipping **** **** Please map /var/run/docker.sock for access to docker service on host. Alternatively you can manually define a remote host address with the docker cli option -H **** **** goaccess already installed, skipping **** **** swag-auto-reload deps already installed, skipping **** **** Docker mod not set up properly, skipping SWAG auto-proxy **** **** libmaxminddb already installed, skipping **** **** Applied the SWAG dashboard mod **** [custom-init] No custom files found, skipping... MOD Auto-reload: Watching the following files/folders for changes (excluding .sample and .md files): /config/nginx [ls.io-init] done. Server ready /config/nginx/proxy-confs/ MODIFY unraid.subdomain.conf Changes to nginx config detected and the changes are valid, reloading nginx /config/nginx/ MODIFY proxy.conf Changes to nginx config detected and the changes are valid, reloading nginx 另外发现一个很奇妙的问题,unraid自带的数据面板信息都不显示,但是我通过GPU Statistics插件加载的GPU数据面板却可以正常显示和实时刷新数据。
September 1, 20232 yr 1 minute ago, worthless-agate6824 said: 日志正常,没有报错提醒。 另外发现一个很奇妙的问题,unraid自带的数据面板信息都不显示,但是我通过GPU Statistics插件加载的GPU数据面板却可以正常显示和实时刷新数据。 我博客有我的联系方式,我远程看一眼吧 Edited September 1, 20232 yr by JackieWu
September 1, 20232 yr Author 2 minutes ago, JackieWu said: 我博客有我的联系方式,我远程看一眼吧 感谢大神,因为我一会要出门,方便的话晚点联系您
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.