【问题标题】:nginx redirect not correctnginx重定向不正确
【发布时间】:2011-12-14 08:49:00
【问题描述】:

我使用 nginx 作为我的 mongrel 的前端。而且mongrel在3001监听,nginx在3000监听。

在我的应用程序中,创建模型后会有重定向。比方说,我向 http://xxxx:3000/users 发布了一个请求,它应该重定向到 http://xxxx:3000/users/1,( 1是新用户的id),但实际上是重定向到http://xxxx/users/1,导致404错误。

为什么3000端口不见了?

【问题讨论】:

    标签: nginx mongrel


    【解决方案1】:

    您在使用proxy_pass 吗?你应该添加这一行:
    proxy_set_header Host $host:3000;

    你需要把你的 nginx 配置放在这里。

    ====

    更好的解决方案:

    proxy_set_header Host $http_host;

    $host不包含端口,$http_host是http头的值,是浏览器添加的。

    【讨论】:

      猜你喜欢
      • 2022-01-04
      • 2021-12-06
      • 1970-01-01
      • 2016-02-28
      • 2018-11-18
      • 2015-02-03
      • 1970-01-01
      • 2016-04-27
      • 2014-08-22
      相关资源
      最近更新 更多