From ab05e55a08ded11c6e5b58dc91ba33087d9a2278 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Tue, 2 Feb 2016 23:44:34 +0000 Subject: lib: Add nginx and uWSGI configuration files nginx and uWSGI are a well-known option for deploying Django applications today - might as well embrace them. Conversely, the mod_python variable and fastcgi service are both deprecated and should not be used. Remove these. Signed-off-by: Stephen Finucane Suggested-by: Thomas Monjalon --- lib/apache2/patchwork.fastcgi.conf | 17 --------------- lib/apache2/patchwork.mod_python.conf | 22 ------------------- lib/nginx/patchwork.conf | 41 +++++++++++++++++++++++++++++++++++ lib/uwsgi/patchwork.ini | 24 ++++++++++++++++++++ 4 files changed, 65 insertions(+), 39 deletions(-) delete mode 100644 lib/apache2/patchwork.fastcgi.conf delete mode 100644 lib/apache2/patchwork.mod_python.conf create mode 100644 lib/nginx/patchwork.conf create mode 100644 lib/uwsgi/patchwork.ini diff --git a/lib/apache2/patchwork.fastcgi.conf b/lib/apache2/patchwork.fastcgi.conf deleted file mode 100644 index a739164..0000000 --- a/lib/apache2/patchwork.fastcgi.conf +++ /dev/null @@ -1,17 +0,0 @@ -NameVirtualHost patchwork.example.com:80 - - DocumentRoot /srv/patchwork/htdocs/ - - Alias /media/ /srv/patchwork/lib/python/django/contrib/admin/media/ - - FastCGIExternalServer /srv/patchwork/htdocs/patchwork.fcgi -socket /srv/patchwork/var/fcgi.sock -pass-header Authorization - - RewriteEngine On - RewriteCond %{REQUEST_URI} !^/(images|css|js|media)/.* - RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^/(.*)$ /patchwork.fcgi/$1 [QSA,L] - - LogLevel warn - ErrorLog /var/log/apache2/patchwork-error.log - CustomLog /var/log/apache2/patchwork-acess.log combined - diff --git a/lib/apache2/patchwork.mod_python.conf b/lib/apache2/patchwork.mod_python.conf deleted file mode 100644 index c46f86c..0000000 --- a/lib/apache2/patchwork.mod_python.conf +++ /dev/null @@ -1,22 +0,0 @@ -NameVirtualHost patchwork.example.com:80 - - DocumentRoot /srv/patchwork/htdocs/ - - Alias /media/ /srv/patchwork/lib/python/django/contrib/admin/media/ - - - SetHandler python-program - PythonHandler django.core.handlers.modpython - PythonPath "['/srv/patchwork', '/srv/patchwork/lib/python'] + sys.path" - SetEnv DJANGO_SETTINGS_MODULE settings - - - - SetHandler None - - - LogLevel warn - ErrorLog /var/log/apache2/patchwork-error.log - CustomLog /var/log/apache2/patchwork-acess.log combined - - diff --git a/lib/nginx/patchwork.conf b/lib/nginx/patchwork.conf new file mode 100644 index 0000000..5479496 --- /dev/null +++ b/lib/nginx/patchwork.conf @@ -0,0 +1,41 @@ +user www-data; +worker_processes 4; +pid /var/run/nginx.pid; + +events { + worker_connections 768; +} + +http { + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; + + gzip on; + gzip_proxied any; + gzip_types text/plain text/css text/javascript application/x-javascript + text/xml application/xml image/svg+xml + application/vnd.ms-fontobject application/x-font-ttf font/opentype; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + server { + location = favicon.ico { access_log off; log_not_found off; } + + location /static { + alias /var/www/patchwork; + expires 3h; + } + + location / { + include uwsgi_params; + uwsgi_pass unix:/run/uwsgi/patchwork.sock; + uwsgi_modifier1 30; + } + } +} diff --git a/lib/uwsgi/patchwork.ini b/lib/uwsgi/patchwork.ini new file mode 100644 index 0000000..4f5dc90 --- /dev/null +++ b/lib/uwsgi/patchwork.ini @@ -0,0 +1,24 @@ +[uwsgi] + +project = patchwork +base = /opt +user = www-data +group = www-data + +chdir = %(base)/%(project) +pythonpath = %(base)/%(project) +module = %(project).wsgi:application + +master = true +processes = 5 +# increase buffer size to avoid "502 bad gateway error" +# "recv() failed (104: Connection reset by peer) while reading response header from upstream" +buffer-size = 16384 + +uid = %(user) +gid = %(group) + +daemonize = /var/log/%(project).log +socket = /run/uwsgi/%(project).sock +chmod-socket = 660 +vacuum = true -- cgit v1.2.3