|
|
Context: excepted secrets like passwords, DBnomics intends to share publicly its production configuration files and methods.
|
|
|
|
|
|
## Web API
|
|
|
|
|
|
### Nginx virtual host
|
|
|
|
|
|
`/etc/nginx/sites-enabled/api.dev.nomics.world.conf`:
|
|
|
|
|
|
```nginx
|
|
|
server {
|
|
|
server_name api.dev.nomics.world;
|
|
|
|
|
|
access_log /var/log/nginx/api.dev.nomics.world-access.log combined;
|
|
|
error_log /var/log/nginx/api.dev.nomics.world-error.log warn;
|
|
|
|
|
|
location / { rewrite ^/(.*)$ /v21/$1 redirect; }
|
|
|
location /v21 { try_files $uri @dbnomics_api_v21; }
|
|
|
|
|
|
location @dbnomics_api_v21 {
|
|
|
include uwsgi_params;
|
|
|
uwsgi_pass localhost:8021;
|
|
|
}
|
|
|
|
|
|
listen [::]:443 ssl ipv6only=on; # managed by Certbot
|
|
|
listen 443 ssl; # managed by Certbot
|
|
|
ssl_certificate /etc/letsencrypt/live/api.dev.nomics.world/fullchain.pem; # managed by Certbot
|
|
|
ssl_certificate_key /etc/letsencrypt/live/api.dev.nomics.world/privkey.pem; # managed by Certbot
|
|
|
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
|
|
|
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
|
|
|
}
|
|
|
|
|
|
server {
|
|
|
if ($host = api.dev.nomics.world) {
|
|
|
return 301 https://$host$request_uri;
|
|
|
} # managed by Certbot
|
|
|
|
|
|
listen 80;
|
|
|
listen [::]:80;
|
|
|
|
|
|
server_name api.dev.nomics.world;
|
|
|
return 404; # managed by Certbot
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### Systemd service file
|
|
|
|
|
|
`/etc/systemd/system/dbnomics-api-v21.service`:
|
|
|
|
|
|
```ini
|
|
|
[Service]
|
|
|
ExecStart=/usr/bin/uwsgi --ini /home/cepremap/production-config/dbnomics-api-uwsgi-v21.ini
|
|
|
Restart=always
|
|
|
User=cepremap
|
|
|
Group=cepremap
|
|
|
LimitNOFILE=65536
|
|
|
|
|
|
[Install]
|
|
|
WantedBy=multi-user.target
|
|
|
```
|
|
|
|
|
|
### uwsgi config
|
|
|
|
|
|
`/home/cepremap/production-config/dbnomics-api-uwsgi-v21.ini`:
|
|
|
|
|
|
```ini
|
|
|
[uwsgi]
|
|
|
socket = localhost:8021
|
|
|
|
|
|
plugin = python3
|
|
|
|
|
|
; mount apps
|
|
|
mount = /v21=dbnomics_api.app:app
|
|
|
|
|
|
; rewrite SCRIPT_NAME and PATH_INFO accordingly
|
|
|
manage-script-name = true
|
|
|
|
|
|
virtualenv = /home/cepremap/virtualenvs/dbnomics-api-v21
|
|
|
|
|
|
processes = 4
|
|
|
enable-threads = true
|
|
|
threads = 2
|
|
|
|
|
|
; Enable then use "uwsgitop :8001" to see processes.
|
|
|
stats = :8001
|
|
|
``` |
|
|
\ No newline at end of file |