V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
yamada
V2EX  ›  问与答

nginx 反代 google,为啥入流量和出流量不一致?

  •  1
     
  •   yamada · 2016-06-30 22:29:21 +08:00 · 1266 次点击
    这是一个创建于 2871 天前的主题,其中的信息可能已经有所发展或是发生改变。

    想要节省流量和加快速度,但是发现在 nginx 服务器上,流入流量要比流出高出 2-4 倍。 反代其他网站也是,怀疑是后端( google 等)的响应没有 gzip ?但是我请求是带了 gzip 啊,这是我的配置:

    worker_processes 1;

    error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid;

    worker_rlimit_nofile 1024; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    
    access_log  /var/log/nginx/access.log  main;
    sendfile        on;
    tcp_nopush     on;
    keepalive_timeout  120;
    gzip  on;
    gzip_types application/json text/plain application/x-javascript application/javascript text/javascript text/css application/xml text/xml;
    gzip_min_length 1k;
    server_tokens off;
    upstream backend{
        server google.com;
    	keepalive 120;
    }
    proxy_temp_path /tmp/cache_tmp;
    proxy_cache_path /tmp/cache levels=1:2 keys_zone=cache1:100m inactive=20m max_size=5g;
    server{
        listen 80;
        location / {
            proxy_pass https://backend;
    		proxy_http_version 1.1;
    		proxy_set_header Range $http_range;
    		proxy_set_header If-Range $http_if_range;
    		proxy_set_header Connection "";
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header Accept-Encoding "gzip";
    		proxy_cache cache1;
            proxy_cache_key $uri$is_args$args;
            proxy_cache_revalidate on;
        }
    }
    

    }

    第 1 条附言  ·  2016-08-11 17:23:08 +08:00
    没有人回复……
    1 条回复    2016-08-11 11:47:32 +08:00
    yamada
        1
    yamada  
    OP
       2016-08-11 11:47:32 +08:00
    。。。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5502 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 07:26 · PVG 15:26 · LAX 00:26 · JFK 03:26
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.