Skip to content

Instantly share code, notes, and snippets.

@ericchen
Last active August 29, 2015 14:03
Show Gist options
  • Save ericchen/5260f63f4e73c2e0971f to your computer and use it in GitHub Desktop.
Save ericchen/5260f63f4e73c2e0971f to your computer and use it in GitHub Desktop.
解决redirect_to跳转丢失子域名

问题描述

使用redirect_to跳转时子域名丢失,比如跳转到subdomain.example.com/admins/users时nginx会帮你解析到subdomain.example.com/admins/.example.com/admins/users

解决方法

在nginx配置文件里面添加如下代码

proxy_redirect off;

比较完全的配置如下:

location / {
    proxy_set_header  X-Real-IP  $remote_addr;
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header  Host $http_host;
    proxy_redirect    off;
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment