V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
autotesting
V2EX  ›  NGINX

nginx 能否将地址中某个短链接进行 urlencode 后转发

  •  
  •   autotesting · 2019-06-09 19:17:49 +08:00 · 4071 次点击
    这是一个创建于 1773 天前的主题,其中的信息可能已经有所发展或是发生改变。

    这是我在 stackoverflow 的提问。

    https://stackoverflow.com/questions/56497316/nginx-only-make-subdirectory-urlencode

    简单说,就是

    http://1111:5000/blue/job/test/ab/build111

    替换为:

    http://abcd.com/blue/job/test%2fab%2fbuild111

    或者

    http://1111:5000/blue/job/test-ac/build222

    替换为

    http://abcd.com/blue/job/test-ac%2fbuild222

    很明显,有时 test/ab/ 需要进行 urlencode test%2fab%2f, 有时候 test-ac/ 需要 urlencodetest-ac%2f, 规则就是前面的 http://1111:5000/blue/job/固定,且最后一个 build111 或者 build222 不固定但是不需要 url 编码。

    不知道 nginx 怎么才能做到?

    7 条回复    2019-06-10 09:52:05 +08:00
    phpfpm
        1
    phpfpm  
       2019-06-09 19:36:10 +08:00
    我建议整体作为 query 然后转义的事情交给后端。。
    lolizeppelin
        2
    lolizeppelin  
       2019-06-09 19:44:29 +08:00   ❤️ 2
    请使用 nginx + lua
    想怎么转就怎么转
    chendy
        3
    chendy  
       2019-06-09 19:57:22 +08:00
    业务是什么,为啥如此难受地转来转去
    37Y37
        4
    37Y37  
       2019-06-09 23:07:56 +08:00
    这么设计有啥特殊的意义?如果没有还是推倒重来吧[手动狗头]
    limuyan44
        5
    limuyan44  
       2019-06-10 09:28:13 +08:00 via Android
    上 lua 吧,不过我觉得这需求绝壁有问题
    autotesting
        6
    autotesting  
    OP
       2019-06-10 09:51:01 +08:00
    @37Y37 @limuyan44 其实是 jenkins 使用 https 后遇到的问题,主要是访问 blueocean 出现 404,经过仔细对比,发现了访问路径不一致的地方。主要是我描述的这样
    autotesting
        7
    autotesting  
    OP
       2019-06-10 09:52:05 +08:00
    @37Y37 @limuyan44

    https://issues.jenkins-ci.org/browse/JENKINS-48159

    If you are having problems with some paths (eg folders) with Blue Ocean, you may need to add the following snippet to your proxy configuration:

    if ($request_uri ~* "/blue(/.*)") {
    proxy_pass http://YOUR_SERVER_IP:YOUR_JENKINS_PORT/blue$1;
    break;
    }
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2935 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 15:21 · PVG 23:21 · LAX 08:21 · JFK 11:21
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.