• 请不要在回答技术问题时复制粘贴 AI 生成的内容
Concise
V2EX  ›  程序员

nginx 的 if 内不允许使用 proxy_set_header 命令吗

  •  
  •   Concise · Feb 3, 2020 · 2708 views
    This topic created in 2292 days ago, the information mentioned may be changed or developed.
    我本来是想在 location 段简单的用 if 判断一下 cookie 来决定要不要添加额外的 header
    if ($http_cookie !~* "BED") {
    add_header Set-Cookie BED=1;
    }
    1 replies    2020-02-03 21:49:17 +08:00
    Concise
        1
    Concise  
    OP
       Feb 3, 2020
    好吧 去官方看了一下有人问过确实是不允许使用
    暂时是用参数做几次中转凑合在用
    if ($http_cookie !~* "BED") {
    set $sid "BED=1";
    }
    if ($http_cookie ~* "PHPSESSID") {
    set $sid $http_cookie;
    }

    proxy_set_header Cookie $sid;
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2917 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 12:47 · PVG 20:47 · LAX 05:47 · JFK 08:47
    ♥ Do have faith in what you're doing.