Add basic configuration files for nginx and uwsgi

This commit is contained in:
Lucas Verney 2018-07-11 16:58:50 +02:00
parent e9b4593abf
commit c18f061548
3 changed files with 75 additions and 1 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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))