Windows + Python + flup + flask + fastcgi + Nginx配置

 

Nginx配置python

# HTTPS
    server {
        listen       443 ssl;
        server_name  kvaccount.xx.io;

        ssl_certificate      "C:/xx/conf/ssl/xx.crt";
        ssl_certificate_key  "C:/xx/conf/ssl/xx.key";

        #ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

        
        location / {
            # 指定 fastcgi 的主機和端口
            fastcgi_pass 127.0.0.1:8008;
            fastcgi_param PATH_INFO $fastcgi_script_name;
            fastcgi_param REQUEST_METHOD $request_method;
            fastcgi_param QUERY_STRING $query_string;
            fastcgi_param CONTENT_TYPE $content_type;
            fastcgi_param CONTENT_LENGTH $content_length;
            fastcgi_param SERVER_PROTOCOL $server_protocol;
            fastcgi_param SERVER_PORT $server_port;
            fastcgi_param SERVER_NAME $server_name;
            fastcgi_pass_header Authorization;
            fastcgi_intercept_errors off;
        }
    }
# HTTP

    server {
        listen       80;
        server_name  kvaccount.xx.io;        
        location / {
            # 指定 fastcgi 的主機和端口
            fastcgi_pass 127.0.0.1:8008;
            fastcgi_param PATH_INFO $fastcgi_script_name;
            fastcgi_param REQUEST_METHOD $request_method;
            fastcgi_param QUERY_STRING $query_string;
            fastcgi_param CONTENT_TYPE $content_type;
            fastcgi_param CONTENT_LENGTH $content_length;
            fastcgi_param SERVER_PROTOCOL $server_protocol;
            fastcgi_param SERVER_PORT $server_port;
            fastcgi_param SERVER_NAME $server_name;
            fastcgi_pass_header Authorization;
            fastcgi_intercept_errors off;
        }
    }

 

fastcgi.pysession

from app import app
from flup.server.fcgi import WSGIServer

if __name__ == '__main__':
    WSGIServer(app,bindAddress=('127.0.0.1', 8008)).run()

啓動python服務:app

python fastcgi.py

啓動Nginx:測試

測試一下,很完美!spa

相關文章
相關標籤/搜索