Current location - Recipe Complete Network - Complete cookbook - Help, Caicai rookie problem, how does django use https protocol?
Help, Caicai rookie problem, how does django use https protocol?
Configure nginx first.

Upstream? Simple _ College _ Server? {

Server? UNIX:/opt/simple _ academy/run/guni corn . sock? fail _ time out = 0; }#? Redirect? All of them? Unencrypted Where to? encryptedserver? {

server_name? Simple. College;

Listen. 80;

Return? 30 1?

$ request _ uri} server? {

server_name? Simple. College;

Listen. 443; ? #? & lt-

ssl? Open; ? #? & lt-ssl_certificate? /etc/SSL/simpleacademy _ cert _ chain . CRT; ? #? & lt-ssl_certificate_key? /etc/SSL/simpleacademy . key; ? #? & lt-

client_max_body_size? 4G;

access_log? /opt/simple _ academy/logs/nginx-access . log;

Error log? /opt/simple _ academy/logs/nginx-error . log;

Location? /? {

proxy_set_header? X-Forwarded-For? $ proxy _ add _ x _ forwarded _ for

proxy_set_header? X-Forwarded-Proto? https? #? & lt-proxy_set_header? Moderator? $ http _ host

Proxy _ redirect? Close;

What if? (! -f? $request_filename)? {

proxy_pass?

Break;

}

}} Then configure django project settings.

Security _ proxy _SSL_HEADER? =? (' HTTP_X_FORWARDED_PROTO ',? https’)

Security _ SSL _ redirection? =? real

SESSION_COOKIE_SECURE? =? real

Are CSRF cookies safe? =? real