Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django所有url SSL_Python_Django_Django Rest Framework - Fatal编程技术网

Python Django所有url SSL

Python Django所有url SSL,python,django,django-rest-framework,Python,Django,Django Rest Framework,我已经在digitalocean上安装了一个django应用程序,使用最小的nginx和gunicorn设置。我使用cloudflare管理dns,还使用cloudflare灵活的ssl。现在的问题是,我所有django生成的url都有http url(),如何使所有url都为https Nginx配置: server { listen 80; client_max_body_size 4G; server_name ***; location / { include p

我已经在digitalocean上安装了一个django应用程序,使用最小的nginx和gunicorn设置。我使用cloudflare管理dns,还使用cloudflare灵活的ssl。现在的问题是,我所有django生成的url都有http url(),如何使所有url都为https

Nginx配置:

server {
listen       80;
client_max_body_size 4G;
server_name  ***;

location / {
    include proxy_params;
    proxy_pass http://unix:**.sock;
}
location /static {
    autoindex off;
    alias **/static_files;
}

location /media {
    autoindex off;
    alias **/media;
}

error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   html;
}
}
Django确实提供了将所有URL重定向到https的设置

将此添加到settings.py文件中

if not DEBUG:
    SECURE_SSL_REDIRECT = True

另外,请查看SSL实施指南。

请参阅相关内容-它会抛出“ERR\u TOO\u MANY\u REDIRECTS”您可以更新您的问题并显示nginx配置吗?因为您的问题是关于将所有请求重定向到django中的https,此设置应该可以工作,但您尚未在nginx中配置SSL。我建议您只看一看其中一个教程。可以找到最低设置。我正在使用cloud flare flexible ssl,它的工作方式如下()。我需要将所有系统生成的url设置为https