-
Notifications
You must be signed in to change notification settings - Fork 5
Install server
Install requirements
sudo apt install nginx wget openssl
nginx config file
You have to create an SSL/TLS certificate (and change the path in the config)
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name SUB.DOMAIN.TLD;
root /var/www/etopa;
index index.html;
ssl_certificate /etc/letsencrypt/live/SUB.DOMAIN.TLD/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/SUB.DOMAIN.TLD/privkey.pem;
add_header Cache-Control no-cache;
expires -1;
location = / {
try_files $uri $uri/ =404;
}
location = /app/ {
try_files $uri $uri/ =404;
}
location ~* \.(js|css|html|woff2|wasm|png|ico|svg|json|txt)$ {
try_files $uri $uri/ =404;
}
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass https://[::1]:4490;
}
}
systemd file
sudo nano /usr/lib/systemd/system/etopa.service
[Unit]
Description=Etopa HTTPS API
After=network.target
[Service]
Type=simple
User=etopa
Group=etopa
WorkingDirectory=/var/lib/etopa
ExecStart=/usr/bin/etopa
KillMode=process
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
Configuration file
sudo nano /etc/etopa.conf
port = 4490
addr = [::]
threads = 2
vlt = 604800
data = data
cert = data/cert.pem
key = data/key.pem
Create user
sudo useradd -M -s /bin/false etopa
Create directories
sudo mkdir -p /var/lib/etopa/data /var/www/etopa
Etopa SSL/TLS certificate
sudo openssl req -x509 -newkey rsa:2048 -keyout /var/lib/etopa/data/key.pem -out /var/lib/etopa/data/cert.pem -days 3650 -nodes -subj '/CN=localhost'
Set file permissions
sudo chown -R etopa:etopa /var/lib/etopa
Download etopa binary
sudo wget -O /usr/bin/etopa https://github.com/ltheinrich/etopa/releases/latest/download/etopa && sudo chmod +x /usr/bin/etopa
Download and extract etopa web files
sudo wget -O /tmp/etopa.tar.xz https://github.com/ltheinrich/etopa/releases/latest/download/etopa.tar.xz
sudo tar xfJ /tmp/etopa.tar.xz -C /var/www/etopa
Edit web config (change API_URL)
sudo nano /var/www/etopa/config.js
Enable and start
sudo systemctl enable etopa.service && sudo systemctl start etopa.service && sudo systemctl restart nginx