diff options
author | Stephen Finucane <stephen.finucane@intel.com> | 2016-02-02 23:44:34 +0000 |
---|---|---|
committer | Stephen Finucane <stephen.finucane@intel.com> | 2016-02-14 16:24:08 +0000 |
commit | ab05e55a08ded11c6e5b58dc91ba33087d9a2278 (patch) | |
tree | 385394f3a73dbc60ba2ce8b521d93e0bf2352a6a | |
parent | 2ad82b755b245e2297856cdbbcf1a3a31025682b (diff) | |
download | patchwork-ab05e55a08ded11c6e5b58dc91ba33087d9a2278.tar patchwork-ab05e55a08ded11c6e5b58dc91ba33087d9a2278.tar.gz |
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 <stephen.finucane@intel.com>
Suggested-by: Thomas Monjalon <thomas.monjalon@6wind.com>
-rw-r--r-- | lib/apache2/patchwork.fastcgi.conf | 17 | ||||
-rw-r--r-- | lib/apache2/patchwork.mod_python.conf | 22 | ||||
-rw-r--r-- | lib/nginx/patchwork.conf | 41 | ||||
-rw-r--r-- | lib/uwsgi/patchwork.ini | 24 |
4 files changed, 65 insertions, 39 deletions
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 -<VirtualHost 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 -</VirtualHost> 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 -<VirtualHost patchwork.example.com:80> - DocumentRoot /srv/patchwork/htdocs/ - - Alias /media/ /srv/patchwork/lib/python/django/contrib/admin/media/ - - <Location "/"> - SetHandler python-program - PythonHandler django.core.handlers.modpython - PythonPath "['/srv/patchwork', '/srv/patchwork/lib/python'] + sys.path" - SetEnv DJANGO_SETTINGS_MODULE settings - </Location> - - <LocationMatch "^/+(images|css|js|media)/"> - SetHandler None - </LocationMatch> - - LogLevel warn - ErrorLog /var/log/apache2/patchwork-error.log - CustomLog /var/log/apache2/patchwork-acess.log combined - -</VirtualHost> 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 |