gpt4 book ai didi

django - 如何停止从本地主机重定向到 https

转载 作者:可可西里 更新时间:2023-11-01 17:24:48 25 4
gpt4 key购买 nike

我有一个使用 Django 的网站。从我们的网站始终重定向为 https。在本地主机上导致问题的问题。错误是:

**An error occurred during a connection to 127.0.0.1:8000. SSL received a record that exceeded the maximum permissible length. Error code: SSL_ERROR_RX_RECORD_TOO_LONG**

如何解决这个问题?拜托我需要你的帮忙。这个问题以前是不存在的。直到现在我都找不到解决方案。

nginx 配置为:

server {
listen 80;
listen [::]:80;

server_name www.website.com;

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

client_max_body_size 6m;

if ($scheme = http) {
return 301 https://website.com$request_uri;

}
location /static {
alias /home/website/staticfiles;
autoindex on;
expires max;
gzip on;
gzip_types text/plain text/css application/json application/x-javascript text/xml
application/xml application/xml+rss text/javascript;
}


location /media {
alias /home/website/media;
autoindex on;
expires max;
}


location / {
proxy_pass http://127.0.0.1:8000/;
proxy_redirect off;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;


}


}

server {
listen 443 ssl;
listen [::]:443 ssl;

server_name IP website.com;

ssl_certificate /home/website/website.com.crt;
ssl_certificate_key /home/website/website.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers '';

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

client_max_body_size 6m;


location /static {
alias /home/website/staticfiles;
autoindex on;
expires max;
gzip on;
gzip_types text/plain text/css application/json application/x-javascript text/xml
application/xml application/xml+rss text/javascript;
}


location /media {
alias /home/website/media;
autoindex on;
expires max;
}

location / {
proxy_pass http://127.0.0.1:8000/;
proxy_redirect off;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;


}
}

最佳答案

在本地运行网站时,您需要禁用重定向到 HTTPS
为此,请在您的设置中将 SECURE_SSL_REDIRECT 设置为 False:

SECURE_SSL_REDIRECT = False

关于django - 如何停止从本地主机重定向到 https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48908543/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com