【问题标题】:curl on django staging server(EC2) redirects to localhostdjango 登台服务器(EC2)上的 curl 重定向到 localhost
【发布时间】:2015-01-30 18:05:47
【问题描述】:

命令 -

curl -I http://stage.servername.com/

响应 -

HTTP/1.1 301 MOVED PERMANENTLY
Server: nginx/1.4.6 (Ubuntu)
Date: Tue, 02 Dec 2014 13:18:45 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
x-frame-options: DENY
Location: https://127.0.0.1:8000/
x-content-type-options: nosniff
P3P: CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"

以下是我的 nginx 设置 - https://gist.github.com/anonymous/f84c5b7bed41b40a3cfd

gunicorn 服务器在 8000 端口运行。

(bz)username@ip-172-31-4-167:~$ ps aux|grep gunicorn
username    2283  0.0  0.5  51912 11028 ?        S    11:42   0:00 /home/username/Envs/bz/bin/python /home/username/Envs/bz/bin/gunicorn bizchat.wsgi:application --workers=3 -D
username    2288  0.0  1.3 136244 28428 ?        S    11:42   0:00 /home/username/Envs/bz/bin/python /home/username/Envs/bz/bin/gunicorn bizchat.wsgi:application --workers=3 -D
username    2289  0.0  1.3 136260 28428 ?        S    11:42   0:00 /home/username/Envs/bz/bin/python /home/username/Envs/bz/bin/gunicorn bizchat.wsgi:application --workers=3 -D
username    2290  0.0  1.7 144484 36860 ?        S    11:42   0:00 /home/username/Envs/bz/bin/python /home/username/Envs/bz/bin/gunicorn bizchat.wsgi:application --workers=3 -D
username    3452  0.0  0.0  10468   924 pts/0    S+   13:09   0:00 grep --color=auto gunicorn

nginx 服务正常。

然而,我正在使用django-secure,但带有以下标志SSLIFY_DISABLE=True

当我打开 url.myapp.com 时,redirects 到 https://127.0.0.1:8000

任何想法,出了什么问题?

【问题讨论】:

    标签: python django nginx amazon-ec2 gunicorn


    【解决方案1】:

    如果没有的话,把它放在你的 nginx.conf 中:

    proxy_set_header Host $host;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-29
      • 2019-12-18
      • 2011-04-22
      • 2014-01-23
      • 1970-01-01
      • 1970-01-01
      • 2021-12-20
      • 2019-02-23
      相关资源
      最近更新 更多