|
|
DBnomics shares publicly its production configuration files and methods, excepted secrets like passwords.
|
|
|
|
|
|
## Web API
|
|
|
|
|
|
This is the configuration we use for https://git.nomics.world/dbnomics/dbnomics-api
|
|
|
|
|
|
### Nginx virtual host
|
|
|
|
|
|
`/etc/nginx/sites-enabled/api.db.nomics.world.conf`:
|
|
|
|
|
|
```nginx
|
|
|
server {
|
|
|
listen 80;
|
|
|
listen [::]:80;
|
|
|
|
|
|
server_name api.db.nomics.world;
|
|
|
|
|
|
access_log /var/log/nginx/api.db.nomics.world-access.log combined;
|
|
|
error_log /var/log/nginx/api.db.nomics.world-error.log warn;
|
|
|
|
|
|
location /v21 {
|
|
|
include uwsgi_params;
|
|
|
uwsgi_pass localhost:8021;
|
|
|
}
|
|
|
location /v21 {
|
|
|
include uwsgi_params;
|
|
|
uwsgi_pass localhost:8022;
|
|
|
}
|
|
|
|
|
|
listen 443 ssl; # managed by Certbot
|
|
|
ssl_certificate /etc/letsencrypt/live/api.db.nomics.world/fullchain.pem; # managed by Certbot
|
|
|
ssl_certificate_key /etc/letsencrypt/live/api.db.nomics.world/privkey.pem; # managed by Certbot
|
|
|
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
|
|
|
|
|
|
# Explicitly allow HTTP for certain users who are behind proxies.
|
|
|
|
|
|
# if ($scheme != "https") {
|
|
|
# return 301 https://$host$request_uri;
|
|
|
# } # managed by Certbot
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### uwsgi config
|
|
|
|
|
|
As `cepremap`, create file `/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
|
|
|
```
|
|
|
|
|
|
As `cepremap`, create file `/home/cepremap/production-config/dbnomics-api-uwsgi-v22.ini`:
|
|
|
|
|
|
```ini
|
|
|
[uwsgi]
|
|
|
socket = localhost:8022
|
|
|
|
|
|
plugin = python3
|
|
|
|
|
|
; mount apps
|
|
|
mount = /v22=dbnomics_api.app:app
|
|
|
|
|
|
; rewrite SCRIPT_NAME and PATH_INFO accordingly
|
|
|
manage-script-name = true
|
|
|
|
|
|
virtualenv = /home/cepremap/virtualenvs/dbnomics-api-v22
|
|
|
|
|
|
processes = 4
|
|
|
enable-threads = true
|
|
|
threads = 2
|
|
|
|
|
|
; Enable then use "uwsgitop :8002" to see processes.
|
|
|
stats = :8002
|
|
|
```
|
|
|
|
|
|
As `root`:
|
|
|
|
|
|
```bash
|
|
|
ln -s /home/cepremap/production-config/dbnomics-api-uwsgi-v21.ini /etc/uwsgi/apps-available/
|
|
|
ln -s /home/cepremap/production-config/dbnomics-api-uwsgi-v22.ini /etc/uwsgi/apps-available/
|
|
|
cd /etc/uwsgi/apps-enabled
|
|
|
ln -s ../apps-available/dbnomics-api-uwsgi-v21.ini .
|
|
|
ln -s ../apps-available/dbnomics-api-uwsgi-v22.ini .
|
|
|
systemctl restart uwsgi.service
|
|
|
```
|
|
|
|
|
|
The logs of uwsgi applications are in `/var/log/uwsgi/app/`. To check that the service is well started, the last lines of `/var/log/uwsgi/app/dbnomics-api-uwsgi-v21.log` should display something like "spawned uWSGI worker 1 (and the only) (pid: 8936, cores: 1)" and not contain any error (grep for "Traceback" keyword).
|
|
|
|
|
|
To test, open https://api.db.nomics.world/v22/ or any previous version deployed. It should display:
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
"_meta": {
|
|
|
"version": "22.0.0"
|
|
|
},
|
|
|
"apidocs_href": "/v22/apidocs",
|
|
|
"message": "This is the home page of DBnomics Web API. Its documentation is here: https://api.db.nomics.world/v22/apidocs"
|
|
|
}
|
|
|
```
|
|
|
|
|
|
## Web UI
|
|
|
|
|
|
This is the configuration we use for https://git.nomics.world/dbnomics/dbnomics-ui
|
|
|
|
|
|
### Nginx virtual host
|
|
|
|
|
|
`/etc/nginx/sites-enabled/db.nomics.world.conf`:
|
|
|
|
|
|
```nginx
|
|
|
server {
|
|
|
listen 80;
|
|
|
listen [::]:80;
|
|
|
|
|
|
server_name db.nomics.world;
|
|
|
|
|
|
access_log /var/log/nginx/db.nomics.world-access.log combined;
|
|
|
error_log /var/log/nginx/db.nomics.world-error.log warn;
|
|
|
|
|
|
location /dashboard {
|
|
|
alias /home/cepremap/dbnomics-dashboard/;
|
|
|
}
|
|
|
|
|
|
location / {
|
|
|
root /home/cepremap/dbnomics-ui-static;
|
|
|
try_files $uri /index.html;
|
|
|
}
|
|
|
|
|
|
listen 443 ssl; # managed by Certbot
|
|
|
ssl_certificate /etc/letsencrypt/live/db.nomics.world-0001/fullchain.pem; # managed by Certbot
|
|
|
ssl_certificate_key /etc/letsencrypt/live/db.nomics.world-0001/privkey.pem; # managed by Certbot
|
|
|
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
|
|
|
|
|
|
if ($scheme != "https") {
|
|
|
return 301 https://$host$request_uri;
|
|
|
} # managed by Certbot
|
|
|
}
|
|
|
``` |
|
|
\ No newline at end of file |
|
|
Moved to https://git.nomics.world/dbnomics/dbnomics-ops |
|
|
\ No newline at end of file |