【问题标题】:Nginx beginner - What will be the regexp for accessing /<path>Nginx 初学者 - 访问 /<path> 的正则表达式是什么
【发布时间】:2020-07-13 12:29:09
【问题描述】:

下面是我正在运行的 nginx.conf 文件,也就是说,当我在我的 VPC 中点击 tester.us-east-2.elb.amazonaws.com 时,我可以将我的请求路由到 github.com,但我想要让我的 tester.us-east-2.elb.amazonaws.com/github 更重要地指向 github.com。我尝试摆弄 conf 文件,但未能成功。有人可以帮忙吗?

    listen       80;
    server_name  tester.us-east-2.elb.amazonaws.com;

    location / {
                   proxy_pass              https://github.com;
                   proxy_redirect          http://tester.us-east-2.elb.amazonaws.com/ https://github.com;   
               }

     location = /40x.html {
                }

【问题讨论】:

  • 你想重定向到 githubhub.com 吗?

标签: nginx nginx-reverse-proxy nginx-config


【解决方案1】:

您是否尝试过以下配置?

 location /github {
   proxy_pass     https://github.com;
   proxy_redirect http://tester.us-east-2.elb.amazonaws.com/github https://github.com;   
}

【讨论】:

  • 是的,我尝试了上述方法但没有运气,因为它会转到 github.com/github 并且失败了。
  • 你希望它只去 github.com 吗?如果是这种情况,只需更新重定向行,如上面的 sn-p
猜你喜欢
  • 2011-02-06
  • 1970-01-01
  • 2014-03-22
  • 2019-03-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-01
相关资源
最近更新 更多