-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Tutorial showing how to install Trek server.
- VPS or just machine with public IP address
- Docker (with compose) and git installed
- domain (optional)
$ git clone https://github.com/jsfraz/trek-server.git
Go to the cloned folder and create .env
file with following content and modify it as you need:
POSTGRES_USER=trek
POSTGRES_PASSWORD=12345678
POSTGRES_PORT=5432
POSTGRES_DB=trek
ACCESS_TOKEN_SECRET=...your secret text...
ACCESS_TOKEN_LIFESPAN=111600
TRACKER_TOKEN_SECRET=...your secret text...
SUPERUSER_USERNAME=root
SUPERUSER_PASSWORD=12345678
CLIENT_URL=https://your-trek.example.com
ENV | Example value | Description |
---|---|---|
POSTGRES_USER | trek | Database user |
POSTGRES_PASSWORD | 12345678 | Database password |
POSTGRES_PORT | 5432 | Database port |
POSTGRES_DB | trek | Database name |
ACCESS_TOKEN_SECRET | ...your secret text... | User access token secret, should be long unique secret text. |
ACCESS_TOKEN_LIFESPAN | 111600 | User access token lifespan in seconds. |
TRACKER_TOKEN_SECRET | ...your secret text... | Tracker access token secret, should be long unique secret text. |
SUPERUSER_USERNAME | root | Trek admin username |
SUPERUSER_PASSWORD | 12345678 | Trek admin password |
CLIENT_URL | https://your-trek.example.com | Trek client URL |
This command runs the compose file and creates the container.
$ docker compose up --build -d
You can omit --build
if you don't want to build server image again. Used when you modify .env
and re-run compose.
Now the server is running on server's http://localhost:8080
Create DNS A
record for subdomain pointing to your machine's public IP.
Create Nginx config file /etc/nginx/conf.d/your-trek-backend.conf
with following config:
Replace your-trek-backend.example.com
with your machine's public IP or optionally DNS name.
server {
listen 80;
server_name your-trek-backend.example.com;
location / {
proxy_pass http://127.0.0.1:8080/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
If you have used domain name in the Nginx configuration, you can generate SSL certificate to use SSL.
Install Certbot:
$ sudo apt install certbot python3-certbot-nginx
Automatically configure HTTPS using Let's Encrypt. Replace your-trek-backend.example.com
with your DNS name:
$ sudo certbot --nginx -d your-trek-backend.example.com
You have installed Trek serever!