You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

同一局域网内访问自建Nginx网站异常缓慢的问题排查求助

同一局域网内访问自建Nginx网站异常缓慢的问题排查求助

我遇到一个非常棘手的问题:只有在网站所在的局域网内访问时,我的个人网站速度异常卡顿。如果用手机蜂窝数据,或者在其他建筑里用笔记本访问,网站速度和普通网站一样快,但只要是连接到网站所在局域网的任何设备,加载页面的时间从0.3秒(正常速度)到3分钟不等,而且0.3秒的正常加载在每个会话里只会出现一次,有时候甚至直接超时加载失败。

这个问题已经持续好几个月了,我在论坛上找了一些配置加到nginx.conf里,但我其实不太懂这些配置的具体作用,也不确定它们是否适合我这种访客极少的小型网站。下面是我的nginx.conf完整配置:

# nginx.conf

worker_processes 5;

error_log logs/error.log;

pid       logs/nginx.pid;

worker_rlimit_nofile 8192;

events {
    worker_connections  4096;
    use poll;
    accept_mutex on;
    multi_accept on;
}

http {
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    include mime.types;
    access_log  logs/access.log;
    keepalive_timeout 75s;
    keepalive_requests 100000;
    server_names_hash_bucket_size 128; # this seems to be required for some vhosts
    client_max_body_size 100k;
    proxy_read_timeout 1;
    proxy_buffering off;
    ssl_session_cache   shared:SSL:10m;
    ssl_session_timeout 10m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    upstream files {
        zone upstreams 64K;
        server 127.0.0.1:2025 max_fails=1 fail_timeout=5s;
        keepalive 2;
    }

    server {
        #listen 80;
        listen 443 ssl;
        ssl_certificate C:/Certbot/live/website.gov/fullchain.pem;
        ssl_certificate_key C:/Certbot/live/website.gov/privkey.pem;
        server_name website.gov;

        location /fs/ {
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_pass http://localhost:3000/;
        }

        location /files/ {
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_pass http://files/;
        }

        location / {
            root html;
        }

        location /e/ {
            add_header Content-Type text/plain;
            return 200 $remote_addr;
        }

        location /movies/ {
            alias E:/movies/;
            autoindex on; #Show table of contents
            autoindex_exact_size off; #Show file size
            autoindex_localtime on; #Show file time
        }

        location /music/ {
            alias E:/memes_and_dumb_garbage/private/music/;
            autoindex on; #Show table of contents
            autoindex_exact_size off; #Show file size
            autoindex_localtime on; #Show file time
        }
    }

    error_page   500 502 503 504  /50x.html;
}

我试过调整这些参数,但问题还是没解决,也搞不清这些配置到底是针对小型网站、中型网站(比如superuser.com)还是大型网站(比如谷歌)的。希望有大佬能帮我分析下问题根源,或者给一些具体的排查方向,非常感谢!

备注:内容来源于stack exchange,提问作者flamingowrangler2869

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 12:48:04