Rewrite HTTP to HTTPS Django

一世执手 提交于 2021-02-08 07:29:34

问题


I currently have a Django web server where I need to have users access through HTTPS. I went through this link Django HTTP to HTTPS and understand I need to implement a rewrite rule but am unsure about which file to modify.

Here is the code snippet in nginx:

server {
   listen 80;
   rewrite ^(.*) https://$host$1 permanent;
}

Although, I am confused as to where this would be placed. Any help would be greatly appreciated!

Reason for all of this is I am implementing an iOS e-commerce application that uses Stripe Connect. But I need to supply an HTTPS redirect URI, not HTTP.

EDIT

So I am trying to go through the tutorial http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html but am getting stuck when adding nginx.

Installing is no problem, but its mainly the part where Im linking uWSGI and nginx together.

The step where I implement mysite_nginx.conf is confusing to me. I already added uwsgi_params to my django project root directory, so thats steps all good. But i feel my problem is linking nginx to the mysite_nginx.conf file. I linked the file to the /usr/local/etc/nginx/sites-enabled/ directory but once I run the server uwsgi --socket :8001 --wsgi-file test.py, then direct the web browser to port 8000, test.py isn't being rendered, the typical nginx intro template is being rendered. I have setup nginx to serve to port 8000 as well.

So I've followed the tutorial very explicitly, i feel, but am getting stuck on the part nginx and uWSGI and test.py

Any help would be awesome! Also, I am using Mac OS not Linux

来源:https://stackoverflow.com/questions/29288484/rewrite-http-to-https-django

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!