首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >NGINX背后的FastCGI应用程序无法检测到使用了HTTPS安全连接

NGINX背后的FastCGI应用程序无法检测到使用了HTTPS安全连接
EN

Stack Overflow用户
提问于 2011-01-31 15:13:48
回答 2查看 17K关注 0票数 16

我在Nginx后面运行FastCGI,需要检测url何时通过HTTPS访问。但是,我的Django web应用程序总是报告连接是HTTP (request.is_secure() == False)。但是,SSL设置正确,并且我已经使用SSL检查器验证了我的https:// urls是安全的。

当请求来自HTTPS url时,如何让Django正确检测?

我的Nginx设置是:

代码语言:javascript
运行
复制
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进程:

代码语言:javascript
运行
复制
python /home/webapp/manage.py runfcgi method=threaded host=127.0.0.1 port=8801 pidfile=/home/webapp/fastcgi.pid 
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4848438

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档