我需要将应用程序部署到产品到子域。 app.mysite.com的DNS A记录具有机器的价值。 Mysite.com的A记录具有不同计算机的IP。堆栈:Nginx,Django,Gunicorn。
Nginx在IP上工作正常,但在子域上调用400。
我尝试添加proxy_set_header值
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
但这没有帮助。
server {
listen 80;
server_name app.mysite.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/user/mysite;
}
location / {
proxy_set_header Host $host;
include proxy_params;
proxy_pass http://unix:/home/user/mysite.sock;
}
}
ALLOWED_HOSTS = [ip of machine,'127.0.0.1', 'app.mysite.com','mysite.com']
我希望应用程序只能在子域中工作。我该如何实现?
最后Nginx进程日志可能有帮助
Aug 10 21:23:59 my-machine systemd[1]: Starting A high performance web server and a reverse proxy server...
Aug 10 21:23:59 my-machine systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument
Aug 10 21:23:59 my-machine systemd[1]: Started A high performance web server and a reverse proxy server.
Aug 10 21:25:09 my-machine systemd[1]: Stopping A high performance web server and a reverse proxy server...
Aug 10 21:25:09 my-machine systemd[1]: Stopped A high performance web server and a reverse proxy server.
答案 0 :(得分:0)
经过数小时的测试和配置,子域在
之后启动sudo systemctl restart gunicorn
在/ etc / systemd / system
中答案 1 :(得分:0)
我用以下方法阻止了所有枪械工人:
pkill gunicorn
然后重新启动gunicorn,在我的特殊情况下是:
PYENV_VERSION=3.5.2 gunicorn -c gunicorn_cfg.py testing_webpage.wsgi --timeout 300 --workers=9 --bind=unix:/opt/peaku_co/run/gunicorn.sock