Deployment Overview of Yourls on Server¶
Prerequisites and Basic Requirements¶
To ensure a successful deployment, the following requirements must be met:
-
Operating System: Ubuntu (recommended).
-
Privileges: Root or sudo access is required for installing dependencies and managing Docker.
-
Ports:
-
443/TCP: External HTTPS traffic. -
8080/TCP: Internal application traffic (restricted to localhost).
FQDN of the final panel on the hostkey.in domain¶
The application is accessible via a specific subdomain template based on your server ID.
| Parameter | Value |
|---|---|
| Prefix | yourls |
| Domain | hostkey.in |
| Full template | yourls{Server_ID}.hostkey.in |
File and Directory Structure¶
The application uses the following directory structure for configuration and data persistence:
-
/opt/yourls/: Main application directory. -
/opt/yourls/mysql-data/: Persistent storage for the MySQL database. -
/root/nginx/: Configuration files for the Nginx reverse proxy. -
/data/nginx/user_conf.d/: SSL and Nginx configuration templates.
Application Installation Process¶
The application is deployed using a combination of Docker Compose and system directory setup:
-
System Preparation: The installation creates specific directories in
/opt/yourlswith restricted permissions (0750) to secure the application data. -
Docker Deployment: The core application components are managed via
docker compose. A configuration file located at/opt/yourls/yourls-compose.ymlis used to orchestrate the services. -
Reverse Proxy Setup: An Nginx container is deployed in
/root/nginxusing acompose.ymlfile to handle SSL termination and route traffic from port 443 to the application's internal port.
Access Rights and Security¶
-
File Permissions: Application directories are set to
0750or0640to ensure only the root user can access sensitive configuration files. -
Network Isolation: The main application container is bound to
127.0.0.1:8080, meaning it is not directly accessible from the public internet, preventing unauthorized direct access and forcing all traffic through the secure Nginx proxy.
Databases¶
The application utilizes a MySQL 8 database for data storage.
-
Connection Method: The application connects to the database container via the internal Docker network using the hostname
mysql. -
Storage Location: Persistent data is stored on the host at
/opt/yourls/mysql-data. -
Database Settings:
-
Name:
yourls -
User:
yourls
Docker Containers and Their Deployment¶
The deployment consists of three primary containers:
Yourls Application Container¶
-
Image:
yourls:latest -
Container Name:
yourls{Server_ID}.hostkey.in -
Ports:
127.0.0.1:8080:8080 -
Environment Variables:
-
YOURLS_DB_HOST:mysql -
YOURLS_DB_NAME:yourls -
YOURLS_DB_USER:yourls -
YOURLS_DB_PASS:yourls -
YOURLS_SITE:https://yourls{Server_ID}.hostkey.in -
YOURLS_USER:root -
YOURLS_PASS: (System generated) -
Restart Policy:
always
MySQL Database Container¶
-
Image:
mysql:8 -
Environment Variables:
-
MYSQL_ROOT_PASSWORD:yourls -
MYSQL_DATABASE:yourls -
MYSQL_USER:yourls -
MYSQL_PASSWORD:yourls -
Volumes:
/opt/yourls/mysql-data:/var/lib/mysql -
Restart Policy:
always
Nginx Proxy Container¶
-
Image:
jonasal/nginx-certbot:latest -
Network Mode:
host -
Environment Variables:
-
CERTBOT_EMAIL:[email protected] -
Volumes:
-
nginx_secrets:/etc/letsencrypt -
/data/nginx/user_conf.d:/etc/nginx/user_conf.d -
Restart Policy:
unless-stopped
Application Update Instructions¶
To update the Yourls application, perform the following steps:
-
Navigate to the application directory:
-
Pull the latest images and restart the services: