我继承了Python / Django项目。我正在为新的更改设置开发服务器,这是实时服务器的直接克隆。我正在尝试配置nginx配置,以便它将停止重定向。
目前它陷入了https重定向循环。如果我查看开发工具中的网络选项卡,我可以看到一个302 GET循环继续。
这是nginx配置文件:
server {
listen 443 ssl;
server_name dev.mywebsite.com;
## DYNAMIC CONTENT
location / {
uwsgi_pass unix:///tmp/website.sock;
include uwsgi_params;
uwsgi_param HTTP_X_FORWARDED_PROTO $scheme;
}
## STATIC CONTENT
location ^~ /static/ {
alias /home/website/src/www/static/;
access_log off;
expires 30d;
gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/css text/javascript application/javascript application/x-javascript;
gzip_buffers 16 8k;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
}
ssl_certificate /home/website/ssl/mywebsite/crt;
ssl_certificate_key /home/website/ssl/mywebsite/key;
## FAV ICON
location = /favicon.ico {
alias /home/website/www/static/img/_app/favcion.ico;
}
}
server {
listen 80;
server_name *.mywebsite.com;
rewrite .* https://$host$request_uri permanent;
}
server {
listen 80;
server_name mywebsite.com;
rewrite .* https://www.mywebsite.com$request_uri permanent;
}
server {
listen 443;
server_name mywebsite.com;
ssl_certificate /home/website/ssl/mywebsite/crt;
ssl_certificate_key /home/website/ssl/mywebsite/key;
rewrite .* https://www.mywebsite.com/ permanent;
}
uwsgi:
[uwsgi]
processes = 1
threads = 1
module = mywebsite.wsgi:application
chdir = /home/website/src/
home = /home/website/venv
stats = /tmp/website.stats
socket = /tmp/website.sock
pidfile = /tmp/website.pid
max-requests = 1000
listen = 128
chmod-socket = 777
harakiri = 60
cpu-affinity = 1
vacuum = true
master = true
no-orphans = true
thunder-lock = true
disable-logging = true
我显然用mywebsite替换了所有的URL。 dev子域也存在并正确指向服务器
如果有人能提供帮助,我们将不胜感激。我在这项任务上花了太多时间