AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 830090
Accepted
SteveL
SteveL
Asked: 2017-02-03 02:36:23 +0800 CST2017-02-03 02:36:23 +0800 CST 2017-02-03 02:36:23 +0800 CST

压缩 uwsgi-nginx 和 nginx 负载均衡器之间的流量

  • 772

我有 7 个 nginx 网络服务器运行一个 python 应用程序并通过 uwsgi 和一个套接字文件将其提供给 nginx,在这 7 个网络服务器前面有一个 nginx 负载均衡器,从负载均衡器向公众发出的流量被正确压缩,导致只有~20Mbps的传出流量,但是由于某种原因从网络服务器和负载均衡器出来的流量没有被压缩,导致负载均衡器的总传入流量(来自服务器子网接口)为400Mbps,每个Web 服务器可以承受大约 70Mbps 的传出流量。

是否应该像在 laod 平衡器上启用 gzip 压缩一样启用它(它在哪里工作)?这里有一些不同的配置吗?

网络服务器 nginx.conf:

user xxx;
worker_rlimit_nofile 99999;
worker_processes  16;

events {
    worker_connections 65535;
}
http {
    proxy_cache_path  /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m;
    proxy_temp_path /tmp;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 620;
        keepalive_requests 20000;
#   types_hash_max_size 2048;
    client_max_body_size 200m;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    #ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    #ssl_prefer_server_ciphers on;

    proxy_buffer_size   128k; 
    proxy_buffers   16 256k;
    proxy_busy_buffers_size   256k;
    uwsgi_buffer_size 128k;
    uwsgi_buffers 16 256k;
    uwsgi_busy_buffers_size 256k;
#   uwsgi_param UWSGI_SCHEME https;
#   uwsgi_param HTTPS on;

    #log info
    log_format  main  '[$time_local] - $remote_addr - $request_time - $remote_user - $upstream_addr - "$request" '
                     '$status $body_bytes_sent "$http_referer" '
                     '"$http_user_agent" "$http_x_forwarded_for" $http_host $http_cookie';
    log_format  body  '[$time_local] - $remote_addr - $request_time - $remote_user - "$request" '
                     '$status $body_bytes_sent "$http_referer" '
                     '"$http_user_agent" "$http_x_forwarded_for" $http_host $request_body $http_cookie';

    access_log off;
    #access_log /home/xxx/log/ng_access.log;
    error_log /home/xxx/log/ng_error.log;

    gzip on;
    gzip_disable "msie6";
        gzip_comp_level 4;
        gzip_types      text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    open_file_cache          max=8000 inactive=60s;
    open_file_cache_valid    120s;
    open_file_cache_min_uses 2;
    open_file_cache_errors   off;
    #uwsgi_buffering  off;

    #the cdn server, listening on port 83
    include /etc/nginx/conf.d/cdn.conf;

    #the xxx app, listening on port 81
    include /etc/nginx/conf.d/xxx.conf;

    #the dealers app, listening on port 82
    include /etc/nginx/conf.d/dealers.conf;

    #a fallback server listening on port 80, it acts as a local "load balancer" in case that we need to use this server without
    #a load balancer
    include /etc/nginx/conflb.d/http_upstreams.conf;
    include /etc/nginx/conflb.d/xxx.conf;
    include /etc/nginx/conflb.d/dealers.conf;
    include /etc/nginx/conflb.d/es.conf;
    include /etc/nginx/conflb.d/db.conf;

}

负载均衡器 nginx.conf:

user nginx;
worker_rlimit_nofile 99999;
worker_processes  15;
pid /run/nginx.pid;
events {
    worker_connections  65535;
}
http {

    include /etc/nginx/conf.d/http_upstreams.conf;

        sendfile        on;
        proxy_busy_buffers_size 128k;
        proxy_buffer_size 64k;
        proxy_buffers 4 64k;
        #proxy_max_temp_file_size 0;
        keepalive_timeout  620;
        gzip  on;
        gzip_comp_level 4;
        gzip_types      text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
        include       mime.types;
        default_type  application/octet-stream;
    client_max_body_size 200m;
    #log info
    log_format  main  '[$time_local] - $remote_addr - $request_time - $remote_user - $upstream_addr - "$request" '
                     '$status $body_bytes_sent "$http_referer" '
                     '"$http_user_agent" "$http_x_forwarded_for" $http_host $http_cookie';
    log_format  body  '[$time_local] - $remote_addr - $request_time - $remote_user - "$request" '
                     '$status $body_bytes_sent "$http_referer" '
                     '"$http_user_agent" "$http_x_forwarded_for" $http_host $request_body $http_cookie';

        access_log  /var/log/nginx/access.log  main;

    real_ip_header CF-Connecting-IP;


        include /etc/nginx/conf.d/db1.conf;
    include /etc/nginx/conf.d/db2.conf;   
        include /etc/nginx/conf.d/es.conf;
    include /etc/nginx/conf.d/st.conf;
    include /etc/nginx/conf.d/xxx.conf;
    include /etc/nginx/conf.d/dealers.conf;

    #catch all server
    server {
        listen 80 default_server;
        rewrite ^(.*) http://www.xxx.gr$1 permanent;
    }
}
load-balancing nginx uwsgi
  • 1 1 个回答
  • 658 Views

1 个回答

  • Voted
  1. Best Answer
    Ashish Gupta
    2017-02-03T05:11:16+08:002017-02-03T05:11:16+08:00

    嘿,伙计,像这样使用 gzip 压缩

        gzip on;
        gzip_http_version 1.1;
        gzip_vary on;
        gzip_comp_level 6;
        gzip_proxied any;
        gzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js image/gif image/jpeg application/atom+xml application/rss+xml text/x-component image/png image/tiff image/vnd.wap.wbmp image/x-icon image/x-jng image/x-ms-bmp image/svg+xml image/webp application/font-woff application/msword application/pdf;
        gzip_buffers 16 8k;
        gzip_disable "MSIE [1-6]\.(?!.*SV1)";
    
    • 1

相关问题

  • 网络负载平衡服务器无法相互通信

  • 用于网络监控的路由/代理 SNMP 陷阱(或 Netflow、通用 UDP 等)的解决方案?

  • 防止拒绝服务攻击的最佳技术是什么?

  • 添加备份互联网连接需要哪些硬件?

  • 什么是最有效的 Windows 负载平衡解决方案?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve