我在Nginx后面运行FastCGI,需要检测url何时通过HTTPS访问。但是,我的Django web应用程序总是报告连接是HTTP (request.is_secure() == False)。但是,SSL设置正确,并且我已经使用SSL检查器验证了我的https:// urls是安全的。
当请求来自HTTPS url时,如何让Django正确检测?
我的Nginx设置是:
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
server {
listen 80;
listen 443 default ssl;
ssl_certificate /home/webapp/ssl.crt
ssl_certificate_key /home/webapp/ssl.key
server_name myapp.com;
access_log /home/webapp/access.log
error_log /home/webapp/error.log
root /home/mywebapp;
location / {
# host and port to fastcgi server
fastcgi_pass 127.0.0.1:8801;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass_header Authorization;
fastcgi_intercept_errors off;
}
}
}
我使用以下命令启动Django FastCGI进程:
python /home/webapp/manage.py runfcgi method=threaded host=127.0.0.1 port=8801 pidfile=/home/webapp/fastcgi.pid
https://stackoverflow.com/questions/4848438
复制相似问题