Django REST Swagger HTTPS请求

Art*_*lko 1 python django django-rest-framework swagger-2.0 django-rest-swagger

如何配置django-rest-swagger获得HTTPS请求?

upd:存在SSL证书,并且所有应用程序都在使用它,但是大摇大摆地发出了HTTP请求。

zai*_*zil 6

将此设置添加到您的中settings.py

SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
Run Code Online (Sandbox Code Playgroud)

有关更多详细信息,请参阅文档 ..

另外,您可能需要确保服务器正在转发,x_forwarded_proto并在nginx上将其添加到服务器配置中的位置:

proxy_set_header  X-Forwarded-Protocol  $scheme;
Run Code Online (Sandbox Code Playgroud)