路由器或反向代理 - 网络故障

路由器或反向代理 - 网络故障

我有一个 edgerouter x sfp 作为互联网的主路由器。该路由器上有一个服务器,它运行着一个叫做 swag 的反向代理 docker,例如 letsencrypt,我使用它从互联网访问 nextcloud 和几个 ngnix docker。

这几乎完美无缺。因此,浏览这些网站和 nextcloud 都很顺利,但当我开始下载大文件时,问题就开始了。

当我通过 Web 浏览器从 nextcloud 下载一个 20GB 的文件时,根据 chrome 的说法,由于“网络故障”而失败。我可以重新启动下载,并在多次重新启动后完成下载(从下载菜单中的 kontext 菜单)。当我从 nginx 站点下载同一个文件时也会发生同样的情况,因此它与 nextcloud 没有直接关系。

但是,当我通过 OpenVPN 连接到我的网络并通过内部 LAN IP 下载文件时,我可以成功下载文件。因此,通过 OpenVPN 使用直接 IP 连接到服务器不会导致 chrome 中出现“网络故障”消息。

那么有人可以帮我找出问题出在哪里吗:

  1. edgerouter x sfp 配置是否错误(我只是添加了端口转发位)
  2. 反向代理是问题吗(这里我从docker本身获取了建议的代理配置)
  3. 或者是其他东西?

编辑1:nginx conf文件:

server {
    listen 443 ssl;
    listen [::]:443 ssl;

    server_name shop.*;

    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;

    location / {
        # enable the next two lines for http auth
        #auth_basic "Username and Password Required";
        #auth_basic_user_file /config/nginx/.htpasswd;

        # enable the next two lines for ldap auth
        #auth_request /auth;
        #error_page 401 =200 /login;

        include /config/nginx/proxy.conf;
        resolver 127.0.0.11 valid=30s;
        set $upstream_grafana nginx;
        proxy_pass http://$upstream_grafana;
    }
}

nextcloud 配置文件:

server {
    listen 443 ssl;
    listen [::]:443 ssl;

    server_name nextcloud.*;
    
    include /config/nginx/ssl.conf;
    
    add_header Strict-Transport-Security "max-age=15552000; includeSubDomains";
            

    location / {
        include /config/nginx/proxy.conf;
        resolver 127.0.0.11 valid=30s;
        set $upstream_nextcloud nextcloud;
        proxy_max_temp_file_size 2048m;
        
        proxy_pass https://$upstream_nextcloud;         
    }
    
    
    location ^~ /.well-known {
        # The following 6 rules are borrowed from `.htaccess`

        location = /.well-known/carddav     { return 301 /remote.php/dav/; }
        location = /.well-known/caldav      { return 301 /remote.php/dav/; }
        # Anything else is dynamically handled by Nextcloud
        location ^~ /.well-known            { return 301 /index.php$uri; }

        try_files $uri $uri/ =404;
    }       
}

答案1

好吧,我自己找到了答案。

这两个 Docker 都基于 nginx 服务器,并且有一个名为 proxy_max_temp_file_size 的属性,用于在使用反向代理的 Docker 时设置临时文件的大小。现在我将其设置为非常低的值(100m),因此永远不会调用超时,因此现在会发生网络故障。您也可以使用 proxy_max_temp_file_size=0 来禁用它,但我不确定哪个更好,所以我目前将其保留为 100m。

相关内容