【问题标题】:Rewrite relative location in nginx重写nginx中的相对位置
【发布时间】:2013-07-09 16:51:33
【问题描述】:

我有带有 varnish(:80) + nginx (:8080) 的服务器。 Nginx 是其他 apache 网络服务器的前端。

在 apache werbserver 上有很多重定向。 重定向使用相对位置,例如:

header('Location: /en/')

所以我得到如下链接:

http://example.com:8080/en/

我无法更改 apache 服务器上的重定向。所以我需要在nginx上重写它。 重定向到http://example.com/en/的最佳方法是什么

【问题讨论】:

    标签: redirect nginx location


    【解决方案1】:

    如果 nginx 正在代理 apache,您将无法像在 apache 中那样使用 Location 标头。您需要在 nginx 中使用 rewrite 指令。本文很好地解释了在apache and nginx 中使用重写。

    鉴于您正在重定向位于 varnish 后面的 nginx 服务器,您可能还会发现以下文章很有用。

    http://danielmiessler.com/blog/handling-redirects-with-varnish-and-nginx

    【讨论】:

      猜你喜欢
      • 2014-12-06
      • 1970-01-01
      • 2016-02-14
      • 2012-04-16
      • 2016-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-10
      相关资源
      最近更新 更多