Nginx代理uwsgi服务配置方法

uwsgi安装

pip install uwsgi

编写配置文件

[uwsgi]
master          = true
processes       = 1
threads         = 2
socket          = 127.0.0.1:3031
chmod-socket    = 660
vacuum          = true
max-requests    = 1000
chdir           = /data/wwwroot/project
wsgi-file       = /data/wwwroot/project/demo/wsgi.py
daemonize       = /data/wwwroot/project/logs/uwsgi.log
req-logger      = file:/data/wwwroot/project/logs/reqlog.log
logger          = file:/data/wwwroot/project/logs/errlog.log

nginx代理配置

location / {
    include uwsgi_params;
    uwsgi_pass  127.0.0.1:3031;
    uwsgi_param X-Real-IP $remote_addr;
    uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for;
    uwsgi_param X-Forwarded-Proto $http_x_forwarded_proto;

    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;

    add_header X-Cache $upstream_cache_status;

    add_header Cache-Control no-cache;
    add_header Access-Control-Allow-Origin *;
}

启动脚本

uwsgi --ini /data/wwwroot/project/uwsgi.ini


  • uwsgi可以直接用作web服务器,这里使用的是用nginx作代理服务器的配置
  • uwsgi一般常用于python项目中的web服务
上一篇:《微信小程序:开发入门及案例详解》—— 2.4 框架页面文件


下一篇:下载频道2013下半年超人气精华资源汇总---全都是免积分下载。