Fourteenth-Day Adventist

  • 首页
  • 随笔
  • 隐私政策
  • RNGesus
  • 摄影画廊
ובחדש הראשון בארבעה עשר יום לחדש פסח ליהוה
ἐάν τι αἰτήσητέ με ἐν τῷ ὀνόματί μου ἐγὼ ποιήσω
  1. 首页
  2. Linux
  3. 正文

Nginx 如何除了指定路径之外都跳转其他域名

2023/03/18 0人点赞 0条评论

问ChatGPT和上网搜索都是告诉我只要在Nginx config里,路径代码之后加个return就行,也就是这样

    location /my-path {
        # handle requests to /my-path locally
        proxy_pass http://localhost:8080;
    }

    # redirect all other requests to another server
    return 302 https://other-server.com$request_uri;

但是我实际上试了下不行,访问my-path也还是会跳转到别的域名,实际上应该这么解决

    location /my-path {
        # handle requests to /my-path locally
        proxy_pass http://localhost:8080;
    }
    location / {
        return 302 https://other-server.com$request_uri;
    }

得把return也放在自己的location里面

标签: Linux 服务器 编程
最后更新:2023/03/18

Fourteenth-Day Adventist

Two more weeks, trust the plan!

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

Fourteenth-Day Adventist

Two more weeks, trust the plan!

标签聚合
随笔 服务器 Dugin bug 编程 Duginism Global South Linux

COPYRIGHT © 2022 Fourteenth-Day Adventist. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang