diff --git a/README.md b/README.md index 706426b..2cb318c 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,8 @@ adapt its behavior: #### Serving in production You can use the `wsgi.py` script at the root of the git repository to serve -the server side part. +the server side part. You can find some `uwsgi` and `nginx` base config files +under the `support` folder. ## Contributing diff --git a/support/nginx/cyclassist.conf b/support/nginx/cyclassist.conf new file mode 100644 index 0000000..8de983f --- /dev/null +++ b/support/nginx/cyclassist.conf @@ -0,0 +1,62 @@ +# UWSGI proxy pass +upstream _cyclassist { + server unix:/run/uwsgi/app/cyclassist/socket; +} + +# Expires map +map $sent_http_content_type $expires { + default off; + text/html epoch; + text/css max; + application/javascript max; + ~image/ max; +} + +server { + listen 443 ssl http2; + server_name SERVER_NAME; + root /var/www/cyclassist/dist; + + access_log /var/log/nginx/cyclo-access.log combined; + error_log /var/log/nginx/cyclo-error.log warn; + + ssl on; + ssl_certificate /etc/letsencrypt/live/cyclo.phyks.me/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/cyclo.phyks.me/privkey.pem; + # Tweak the SSL ciphers and so on, see https://wiki.mozilla.org/Security/Server_Side_TLS. + + # Enable GZIP + gzip on; + gzip_disable "msie6"; + gzip_vary on; + gzip_proxied any; + gzip_comp_level 6; + gzip_buffers 16 8k; + gzip_http_version 1.1; + gzip_min_length 256; + gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon; + + # Cache control + expires $expires; + location ~* \.(?:woff2?|eot|ttf|otf?g) { + expires max; // Max caching for font files + } + + # Proxy pass the API calls to the server part + location /api { + include uwsgi_params; + uwsgi_pass _cyclassist; + } +} + + +server { + listen 80; + server_name SERVER_NAME; + + root /dev/null; + + include /etc/nginx/snippets/common_vhost.conf; + + return 301 https://$server_name$request_uri; # Redirect to HTTPS +} diff --git a/support/uwsgi/cyclassist.ini b/support/uwsgi/cyclassist.ini new file mode 100644 index 0000000..69ce20f --- /dev/null +++ b/support/uwsgi/cyclassist.ini @@ -0,0 +1,11 @@ +[uwsgi] +socket = /run/uwsgi/app/cyclassist/socket +chdir = /var/www/cyclassist +master = true +plugins = python +venv = /var/www/cyclassist/.venv +file = wsgi.py +uid = www-data +gid = www-data +env = DATABASE=mysql://USER:PASSWORD@HOST/cyclassist +log-format = [pid: %(pid)|app: -|req: -/-] (%(user)) {%(vars) vars in %(pktsize) bytes} [%(ctime)] %(method) %(uri) => generated %(rsize) bytes in %(msecs) msecs (%(proto) %(status)) %(headers) headers in %(hsize) bytes (%(switches) switches on core %(core))