问题描述
我在后端运行一个 django 应用程序,并且在它前面有 gunicorn + Nginx。
在/etc/systemd/system/gunicorn.service
[Service]
User=user
Group=www-data
WorkingDirectory=/home/user/dev/backend/RecruitRest/recruit
ExecStart=/home/user/miniconda3/envs/hire10x/bin/gunicorn --access-logfile /home/shivanand3939/dev/gunicorn.access.log --error-logfile /home/shivanand3939/dev/gunicorn.error.log --timeout 1000 -k eventlet --workers 1 --bind unix:/home/shivanand3939/dev/backend/RecruitRest/recruit/recruit.sock recruit.wsgi:application
这会引发 CORS 错误,因为 worker-class 是 eventlet, 但是如果删除那部分,即如果我从上面的代码中删除“-k eventlet”,我的应用程序运行良好
location / {
#include proxy_params;
# proxy_pass http://unix:/home/shivanand3939/prod/RecruitRest/recruit/gunicorn.sock;
# proxy_pass http://127.0.0.1:8000/;
add_header Cache-Control private;
add_header Cache-Control no-cache;
add_header Cache-Control no-store;
add_header Cache-Control must-revalidate;
add_header Pragma no-cache;
client_max_body_size 100M;
proxy_buffering off;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
....<CORS SPECIFIC CODE> }
我添加了一些规则,如文档中提到的关闭proxy_buffering:http://docs.gunicorn.org/_/downloads/en/19.x/pdf/ 第 35 页
我需要以异步模式运行 gunicorn(因为我有一些阻塞请求)而不是同步模式。我需要做哪些改变
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)