昨天测试的是uwsgi,
为了能运行在alphine的docker上面,
(听说uwsgi正在改进不是基于于gcc库的应用),
改进一下gunicorn的配置,来实现跟昨天同样的多站点配置。
其实,在配置gunicorn时,它本身的配置不用变,
只要更改nginx为其增加多一级目录即可。
gunicorn.conf
bind = "0.0.0.0:9090"
workers = 12 #workers是工作线程数,一般设置成:2 * 服务器CPU个数 + 1
errorlog = '/var/log/xxx/gunicorn.error.log'
accesslog = '/var/log/xxx/gunicorn.access.log'
#loglevel = 'debug'
#proc_name = 'gunicorn_xxx'
nginx.conf
upstream xxx_host {
server ip:9090;
}
server {
listen 80;
server_name localhost;
location /prism/ {
# include uwsgi_params; #注释这两行为uwsgi
# uwsgi_pass xxx_host; #多目录实现在uwsgi配置
proxy_pass http://xxx_host; #注意有http哟
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header SCRIPT_NAME /xxx; #这种就可以凭空多一级目录
proxy_set_header REMOTE_USER $remote_user;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 1000m;
client_body_timeout 5m;
proxy_connect_timeout 5m;
proxy_read_timeout 5m;
proxy_send_timeout 5m;
}
}
gunicorn -c gunicorn.conf settings.wsgi