This Django app is called by Nginx, which behaves as a reverse proxy to client requests. Here is the nginx configuration file:
# HTTP configuration
# Default HTTP server: always redirect to HTTPS
server {
listen 80 default_server;
server_name _;
return 301 https://$host$request_uri;
}
# HTTPS server
server {
listen 443;
server_name search-api.het.io;
if ( $http_host !~* ^(search-api\.het\.io)$ ) {
return 444;
}
ssl on;
ssl_certificate /etc/letsencrypt/live/search-api.het.io/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/search-api.het.io/privkey.pem; # managed by Certbot
charset utf-8;
# max upload size (adjust to taste)
client_max_body_size 10M;
location / {
return 301 $scheme://$host/v1;
}
location /static {
alias /home/ubuntu/hetmech-backend/dj_hetmech/static;
}
location /v1 {
proxy_pass http://127.0.0.1:8001/v1;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
}
}
The directory /home/ubuntu/hetmech-backend/dj_hetmech/static (which holds static files for API view) should be populated by the following management command:
python manage.py collectstatic
Gunicorn is started at boot time by supervisord, with the following configuration:
command=/home/ubuntu/miniconda3/envs/hetmech-backend/bin/gunicorn dj_hetmech.wsgi:application --bind 127.0.0.1:8001 --error-logfile /tmp/hetmech-g
unicorn.log -w 3
directory=/home/ubuntu/hetmech-backend/
user=nobody
group=nobody
autostart=true
autorestart=true
priority=991
stopsignal=KILL
This Django app is called by Nginx, which behaves as a reverse proxy to client requests. Here is the nginx configuration file:
The directory
/home/ubuntu/hetmech-backend/dj_hetmech/static(which holds static files for API view) should be populated by the following management command:Gunicorn is started at boot time by supervisord, with the following configuration: