This repository contains detailed instructions on how to set up the production environment for:
- REST API
- Admin panel
on Ubuntu.
To set up the environment in the most basic scenario, you need at least one server (Ubuntu). It needs to meet these conditions:
- Docker installed and running (installation guide)
- Nginx installed (installation guide)
- You need to purchase a domain for your server. Ultimately, you need two subdomains for admin panel and API. In this document we'll assume your domains are
admin.mydomain.comandapi.mydomain.com.
- Configure your domain to point to your server IP via DNS.
- Install and start Nginx:
sudo apt update
sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx-
Add privacy policy to your server
You are responsible for managing your respondents' data, therefore you must provide a privacy policy. Respondents will have to accept it after their first login to the mobile app. Add the privacy policy as HTML documents in
/var/www/html/privacy-policy. Currently three languages are supported: English (en.html), Chinese (cn.html), and Polish (pl.html). If you do not provide a language-specific policy, the English version (en.html) will be used as the default. In the future, additional languages may be supported as the mobile app evolves. -
Configure Nginx to proxy requests
Copy the configuration below to
/etc/nginx/sites-available/default, replacingapi.mydomain.comandadmin.mydomain.comwith your actual domains.
server {
listen 80;
server_name api.mydomain.com;
location / {
proxy_pass http://127.0.0.1:8083;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /privacy-policy/ {
root /var/www/html;
try_files $uri $uri/ =404;
}
}
server {
listen 80;
server_name admin.mydomain.com;
location / {
proxy_pass http://127.0.0.1:8084;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /privacy-policy/ {
root /var/www/html;
try_files $uri $uri/ =404;
}
}-
Ensure http mapping is present
Ensure that the
httpsection in/etc/nginx/nginx.confcontains the following configuration:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}If not, add it at the top of the `http` section.
- Reload Nginx to apply changes
sudo nginx -s reload- Verify Nginx is running
sudo systemctl status nginx-
Setup SSL with Let’s Encrypt
Remember to replace the domains.
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d api.mydomain.com -d admin.mydomain.comTo set up the environment, follow the detailed instructions for the variant you're interested in: