错误“您正在通过HTTPS访问开发服务器,但它只支持HTTP” [英] Error "You're accessing the development server over HTTPS, but it only supports HTTP"

查看:3797
本文介绍了错误“您正在通过HTTPS访问开发服务器,但它只支持HTTP”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当我尝试编写http:// ....等服务器链接时,它会重定向到https:/ /和终端:

 消息错误的HTTP / 0.9请求类型('\ x16 \ x03 \ x01 \ x00 \x8b \ x01 \ x00 \ x00 \ x87 \ x03 \ x01 \ \ x118兑J [\\'x19 [Òç\x01< O')
您正在访问开发服务器通过HTTPS,但它只支持HTTP。


解决方案

我认为你应该创建不同的settings.py(base_settings .py,local_settings.py,production_settings.py)。在您的settings.py中执行以下操作:

  import socket 
if socket.gethostname()== Raouf-PC:来自local_settings import的
*

将'Raouf-PC'更改为您PC的主机名。



P:S:我正在使用Windows 10.



完成后,将以下数据放入您的production_settings.py并保存。然后清除浏览器缓存并在开发服务器中访问您的站点。

  SESSION_COOKIE_SECURE = True 
CSRF_COOKIE_SECURE = True
SECURE_SSL_REDIRECT = True

如果上述情况不符合您的需求,请在您的local_settings.py粘贴中以下数据,保存并清除您的浏览器缓存并访问您的网站。

  SESSION_COOKIE_SECURE = False 
CSRF_COOKIE_SECURE = False
SECURE_SSL_REDIRECT = False

注意:在production_setttings.py和local_settings.py的开头放:

 来自base_settings.py import * 

您的基本设置应包含将在本地服务器和生产服务器上使用的设置,因此您不会每次都重复这些设置。



< p:P:S如果我的答案被接受,我会把它献给那些以某种方式帮助过我的SO人。这是我第一次回答问题。我希望将来能做得更多。 :)


When I try to write the server link like http:// .... it redirects to https:// and in the terminal :

message Bad HTTP/0.9 request type ('\x16\x03\x01\x00\x8b\x01\x00\x00\x87\x03\x01Ð\x118¿JÄ\x19[Òç\x01<O')
You're accessing the development server over HTTPS, but it only supports HTTP.

解决方案

I think you should create different settings.py ( base_settings.py, local_settings.py, production_settings.py). And in your settings.py do something like this:

import socket
if socket.gethostname()=="Raouf-PC":
    from local_settings import *

Change 'Raouf-PC' to the hostname of your PC.

P:S: I'm using Windows 10.

After doing that place the below data in your production_settings.py and save. Then clear your browser cache and visit your site in development server.

SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
SECURE_SSL_REDIRECT = True

If the above doesn't suit your needs, then in your local_settings.py paste the below data, save and clear your browser cache and visit your site.

SESSION_COOKIE_SECURE = False
CSRF_COOKIE_SECURE = False
SECURE_SSL_REDIRECT = False

Note: at the beginning of production_setttings.py and local_settings.py put:

from base_settings.py import *

Your base settings should contain 'settings' that will be used both on local and production server so you won't be repeating it everytime.

P:S If my answer is accepted, I dedicate it to the good people on SO who have helped me in one way or the other. This is my first time of answering a question. I hope to do more in the future. :)

这篇关于错误“您正在通过HTTPS访问开发服务器,但它只支持HTTP”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆