我为我的网站使用nginx + gunicorn + django。 以下是我的gunicorn.conf文件: description "Gunicorn daemon for Django project" start on (local-filesystems and net-device-up IFACE=eth0) stop on runlevel [!12345] # If the process quits unexpectadly trigger a respawn respawn setuid django setgid django chdir /home/django # export LC_ALL=en_US.UTF-8 # export LC_LANG=en_US.UTF-8 # export LANG=en_US.UTF-8 exec gunicorn \ –name=eduwiki \ –pythonpath=eduwiki \ –bind=0.0.0.0:9000 […]
在Debian服务器上运行Django应用程序时,是否应该创build某种应用程序用户(例如“myappuser”),并以该用户身份运行gunicorn进程,或者可以/以root身份运行gunicorn进程? 以root身份运行会造成安全风险吗? 我已经使用APT安装了gunicorn,而不是将其安装在虚拟环境中。 以应用程序用户身份运行它似乎使configuration更加困难,因为您必须授予该用户写入日志文件,PID文件等的权限。以root身份运行它似乎更容易。 exec gunicorn $DJANGO_WSGI_MODULE:application \ –name myapp \ –user=$USER \ # <- who should this be? –group=$GROUP \
我在同一台虚拟机上运行GitLab和Taiga.io (即共享相同的IP)有困难。 两者都使用nginx。 我的虚拟机运行Debian 8。 我遵循Debian 8的GitLab的经典Omnibus安装 ,当我在浏览器上input我的虚拟机的IP时,gitlab被正确的服务,并且一切顺利。 然后closures它( sudo gitlab-ctl stop ),然后按照生产环境设置安装Taiga。 根据该文档,它使用Gunicorn和Circus for taiga-back(服务于REST API)以及用于服务前端的nginx。 一旦/etc/nginx/sites-available|enabled/taiga , ~/taiga-back/settings/local.py和~/taiga-front-dist/dist/conf.json都使用相同的IP地址设置,而nginx重新启动( sudo service nginx restart )一切顺利。 现在,可以使用不同的端口(比如说8080 )来更改上述的所有Taiga IP地址,重新启动nginx,并且现在通过IP地址8080提供Taiga。 一切都好! 当我重新启动GitLab( sudo gitlab-ctl start )时,它说一切顺利。 但是,当我尝试访问它(在默认端口80),我得到一个502 ! 如果我切换Taiga并重新启动GitLab,hoho,GitLab可用! 基本上,我只能单独拥有它们,但不能同时拥有它们。 我也尝试在Taiga 80端口上保留Taiga,并在8080端口上移动GitLab(通过更改/etc/gitlab/gitlab.rb文件中的端口并运行sudo gitlab-ctlr reconfigure ),但是我从未设法成功运行它。 我也试着configurationGitLab使用系统nginx(而不是embedded的),也就是Taiga使用的系统。 为此,我在gitlab.rb后面的gitlab.rb禁用了nginx,并使用了这个omnibus(non-ssl)配方: ## GitLab 8.3+ ## ## Lines starting with two hashes […]
我用一个Django项目(Ubuntu 14.04机器)的nginx反向代理使用gunicorn 19.7.1 appserver。 ps aux | grep gunicorn | grep -v grep | wc -l ps aux | grep gunicorn | grep -v grep | wc -l产量3043 。 而在/etc/init/gunicorn.conf ,我一直有-w 33 。 然而,即使我做sudo service gunicorn stop和sudo service gunicorn start这些额外的工作者坚持。 我如何杀死外来的工人? 我试过了: sudo service gunicorn stop和sudo service gunicorn start没有工作。 接下来,我已经build议了两种方法来杀死外来的工人。 我试了他们 – 他们也没有成功。 基本上,当我尝试他们,没有任何反应。 这是第一种方法: […]
我有一个通过Gunicorn运行的WSGI Python应用程序: CONFIG = { 'bind': "unix:{}".format(os.path.join(RUN_DIR, "brain.sock")), 'preload_app': False, # supervisord requires that the child process runs in foreground 'daemon': False, … } 它通过Nginx的套接字文件接收HTTP请求: server { … location / { proxy_pass http://unix:$root/run/brain.sock:; … } Gunicorn通过Supervisord运行: [program:myapp] command = venv/bin/gunicorn -c gunicorn.conf.py myapp.wsgi:application … 我正在考虑一种无需停机和等待时间来部署我的应用程序的方法。 每个工作人员最多可能需要30秒才能填满caching。 我的想法是这样部署的: 用新的代码启动第二个Gunicorn,它将监听另一个套接字文件。 等到应用程序开始,所有的caching被填满。 重命名套接字文件以指向Nginx使用的位置。 Nginx仍然会将请求发送到旧套接字。 用旧的应用程序版本closures老Gunicorn。 Nginx将会看到socket被closures,并且会从同一个地方重新打开一个新的socket。 这会工作吗? 我是否重新发明了轮子?
我正在尝试使用Gunicorn和NGINX来build立一个开发环境。 遵循本教程: http : //ijcdigital.com/blog/django–gunicorn-and-nginx-setup/ 我得到以下错误: (WebApp)sl@cker:~/MyApps/WebApp$ gunicorn_django –bind=127.0.0.1:8001 2012-07-12 14:04:30 [5997] [INFO] Starting gunicorn 0.14.5 2012-07-12 14:04:30 [5997] [ERROR] Connection in use: ('127.0.0.1', 8001) 2012-07-12 14:04:30 [5997] [ERROR] Retrying in 1 second. 2012-07-12 14:04:31 [5997] [ERROR] Connection in use: ('127.0.0.1', 8001) 2012-07-12 14:04:31 [5997] [ERROR] Retrying in 1 second. 2012-07-12 14:04:32 [5997] [ERROR] Connection […]
如果我运行: $ sudo service nginx status * nginx is not running 然后我运行: $ sudo service nginx start Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) … nginx: [emerg] still could not bind() 所以我杀了它: sudo fuser -k 80/tcp 所以我尝试再次启动Nginx: $ […]
我需要configurationnginx + gunicorn才能够在两个服务器上传大于默认最大大小的文件。 我的nginx .conf文件如下所示: server { # … location / { proxy_pass_header Server; proxy_set_header Host $http_host; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Scheme $scheme; proxy_connect_timeout 60; proxy_pass http://localhost:8000/; } } 这个想法是允许两个地点20M的请求: /admin/path/to/upload?param=value /installer/other/path/to/upload?param=value 我已经尝试添加location指令在相同的水平比我在这里粘贴(获得404错误),也试图将它们添加到location /指令(获得413 Entity Too Large错误)。 我的位置指令看起来像这些最简单的forms: location /admin/path/to/upload/ { client_max_body_size 20M; } location /installer/other/path/to/upload/ { client_max_body_size 20M; } 但他们不工作(实际上我testing了很多组合,我绝望地想着这个。 请帮助如果可以的话:我需要设置哪些设置才能使其工作? 非常感谢!
我承认跑了这个: sudo update-rc.d nginx defaults 这似乎消灭了nginx的设置。 像sudo service nginx start这样的Nginx命令在执行时不再返回任何东西。 但是,我的django应用程序的nginx文件仍然存在于: sudo vim /etc/nginx/sites-enabled/myapp sudo vim /etc/nginx/sites-available/myapp 我在nginx上运行了一个GREP,得到: /etc/nginx/sites-available/myapp包含: server { server_name ec2-xxxx.compute-1.amazonaws.com; access_log /home/ubuntu/virtualenv/myapp/error/access.log; error_log /home/ubuntu/virtualenv/myapp/error/error.log warn; connection_pool_size 2048; root /home/ubuntu/virtualenv/myapp/homelaunch/; location /static/ { alias /home/ubuntu/virtualenv/myapp/homelaunch/static/; #alias /static/; #root /home/ubuntu/virtualenv/myapp/homelaunch/; } location / { proxy_pass http://127.0.0.1:8001; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #proxy_set_header X-Forwarded-Host […]
我的nginxconfiguration文件如下。 server { listen 80; server_name http://hg.rawdatatech.com; location / { proxy_pass http://127.0.0.1:8000; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /static/ { alias /home/home-garden/staticfiles/; } } 当我运行我的Django应用程序使用这个configuration,我看到“可疑的符号错误”和连接拒绝错误nginx错误日志。 我的configuration有错吗?