【问题标题】:Nginx doesn't redirect mutilple locationsNginx 不会重定向多个位置
【发布时间】:2018-07-18 23:29:28
【问题描述】:

我正在关注这个tutorial,一切正常,直到我尝试使用多个位置,例如:

location /app1 {
    proxy_pass http://localhost:8080;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}

location /app2 {
    proxy_pass http://localhost:8081;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}

当我尝试调用它们时,它不会重定向并返回 404。

如果我这样做,它可以工作,但这样我只能使用一个应用程序,这不是我想要的......

location / {
    proxy_pass http://localhost:8080;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}

谁能帮帮我?

【问题讨论】:

  • 或许/app1/ ?
  • 不敢相信事情这么简单!有效!谢谢!!!
  • 哈哈,太棒了!很高兴听到这个消息!

标签: nginx location reverse-proxy


【解决方案1】:

根据我们在 cmets 中的讨论:/app1/ ;)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-14
    • 1970-01-01
    • 1970-01-01
    • 2019-01-28
    • 1970-01-01
    • 2021-04-15
    • 1970-01-01
    相关资源
    最近更新 更多