[PATCH 1/2] lib: Add nginx and uWSGI configuration files
Stephen Finucane
stephen.finucane at intel.com
Sun Feb 14 06:54:07 AEDT 2016
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 at intel.com>
Suggested-by: Thomas Monjalon <thomas.monjalon at 6wind.com>
---
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
-<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
--
1.7.4.1
More information about the Patchwork
mailing list