V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
浏览器插件 - Stay
侧边栏化你的浏览器 支持标签页管理,用户脚本,书签同步,标记广告,网页暗黑…
Promoted by ris
awker
V2EX  ›  NGINX

openresty 如何使用 lua 实现 map 的这个功能?

  •  
  •   awker · 2019-12-12 10:36:51 +08:00 · 4243 次点击
    这是一个创建于 2153 天前的主题,其中的信息可能已经有所发展或是发生改变。

    根据请求 cookie 设置不同的变量

    map $http_cookie $rootpath {
        "~gray" "/data/gray";
        default "/data";
    }
    server {
        listen 80;
        server_name devtest.foobar.cn;
        access_log logs/devtest_access.log  main;
        index index.html index.htm index.jsp index.do;
        root /data;
    
        location ~ /omg {
            root $rootpath;
            try_files $uri $uri/;
        }
    
    
    1 条回复    2019-12-12 11:32:22 +08:00
    sanmaozhao
        1
    sanmaozhao  
       2019-12-12 11:32:22 +08:00
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   3203 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 11:36 · PVG 19:36 · LAX 03:36 · JFK 06:36
    ♥ Do have faith in what you're doing.