NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
kokol
V2EX  ›  NGINX

nginx proxy_pass upstream 长连接-动态变量

  •  
  •   kokol · Sep 23, 2020 · 2550 views
    This topic created in 2069 days ago, the information mentioned may be changed or developed.
    从 nginx 到 server 的连接是短连接,现在想设置长连接, 看网上的设置都是 keepalive,proxy_http_version 1.1,proxy_set_header Connection "" 3 个参数
    http {
    upstream BACKEND {
    server 192.168.0.1:8080 weight=1 max_fails=2 fail_timeout=30s;
    server 192.168.0.2:8080 weight=1 max_fails=2 fail_timeout=30s;
    keepalive 300; // 这个很重要!
    }
    server {
    listen 8080 default_server;
    server_name "";
    location / {
    proxy_pass http://BACKEND;
    proxy_http_version 1.1; // 这两个最好也设置
    proxy_set_header Connection "";
    }
    }
    }

    但是我的 nginx.conf 里有 lua 写的代码,proxy_pass 是变量的形式

    server {
    listen 8080 default_server;
    server_name "";
    location / {

    -- 代码里有设置$upstream 、$arg_symbol 、$args 的变量
    proxy_pass $upstream$arg_symbol$args;
    }
    }
    }

    我怎样改成 upstream 的呢,我看 upstream 里只支持 IP 、域名、端口的形式
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3093 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 13:43 · PVG 21:43 · LAX 06:43 · JFK 09:43
    ♥ Do have faith in what you're doing.