Practice Test - Docker Deployment of URL Shortening Service YOURLS

A service for shortening URLs, allowing you to operate a URL shortening service on your own server. It provides complete control over your data, including simple statistics, analysis, and numerous plugins.

December 30, 2023: Escaping the clutches of the MySQL database, embracing its branch, MariaDB.

Reason: In the event of an unexpected power failure, MySQL reported errors when Docker was started, which could not be resolved. In comparison, MariaDB provides a better solution.

Purpose

This is a URL shortening service that enables you to run a URL shortening service on your own server. Its features include complete control over your data, including statistics, analysis, and the ability to install various plugins. It also allows for the management of links related to Clash.

Existing online URL shortening solutions often come with obvious drawbacks, some of which involve hidden and specific redirections.

Existing URL Shortening Resources

Short Links
- https://t.hk.uy/b5kg
- https://netlify.carlzeng.com currently does not support the domain name you entered. Use this URL to shorten: https://sage-halva-bac054.netlify.app
- https://t.hk.uy/b6qy

Easily Shorten Links
- https://goo.su/BwRaE1T
- https://goo.su/prTA5T5

URL Shortener
- https://tinyurl.com/yurgh2fm

Traditional Free URL Shortening Tool
- http://s8u.cn/HIG7o
- Elegant, but unable to accept: first redirects to a link, then restores the original URL.

Change of Perspective:
Use your own domain name for shorter ‘Nname’;
Setting up your own URL shortening service

Implementation Details and Process Notes

Visual Guide

[Fun Docker Project] Setting up your own URL Shortening Service—YOURLS in 10 minutes](https://iwanlab.com/docker-compose-install-yourls/)
[Server] How to Set Up Your Own Private Short URL Service Using Docker](https://www.hellosanta.com.tw/knowledge/category-38/post-219)

Process, Issues Encountered, and Solutions

In the ‘bt’ directory, a docker-compose template was created,
docker-compose -f yours.yml up
Then, a firewall rule was added to allow traffic through port 8200

After adding a firewall rule, it was impossible to connect to the ‘bt’ panel

Setting up your own URL shortening service

Old Version

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
version: "3.5"
services:

mysql:
image: mysql:5.7.42 # If incorrect database configuration occurs, or there is a failure to connect to the database with the message: "PDOException: SQLSTATE[HY000] [1045] Access denied for user 'yourls'@'yourls_service.yourls_default' (using password: YES)", changing 5.7.22 to 5.7 may resolve it
environment:
- MYSQL_ROOT_PASSWORD=my-secret-pw
- MYSQL_DATABASE=yourls
- MYSQL_USER=yourls
- MYSQL_PASSWORD=yourls
volumes:
- ./mysql/db/:/var/lib/mysql
- ./mysql/conf/:/etc/mysql/conf.d # Caution: It is important to note that the original author added a ".d" character (probably due to automatic tab input in debian), which caused troubleshooting effort for half an hour before successful resolution
restart: always
container_name: yourls_mysql # This naming convention helps avoid problems with duplicate names when there are multiple Docker instances, and it provides clear documentation

yourls:
image: yourls
restart: always
ports:
- "8200:80"
environment:
YOURLS_DB_HOST: mysql
YOURLS_DB_USER: admin
YOURLS_DB_PASS: admin
YOURLS_DB_NAME: yourls
YOURLS_USER: admin # Choose your own username
YOURLS_PASS: 123admin@@ # Choose your own login password
YOURLS_SITE: https://c.carlzeng.com:4443 # Replace with your own domain and ensure that Nginx Proxy Manager points to this address
YOURLS_HOURS_OFFSET: 8
volumes:
- ./yourls_data/:/var/www/html
container_name: yourls_service
links:
- mysql:mysql

Reported Error:

1
2
3
4
5
6
7
8
9
10
11
12
13
yours_mysql     | 2023-11-07 13:33:44+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
yours_mysql | 2023-11-07 13:33:44+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.44-1.el7 started.
yours_mysql | 2023-11-07 13:33:44+00:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config
yours_mysql | command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.5snRuPe4br
yours_mysql | mysqld: Can't read dir of '/etc/mysql/conf.d/' (Errcode: 13 - Permission denied)
yours_mysql | mysqld: [ERROR] Fatal error in defaults handling. Program aborted!
yours_mysql exited with code 1
yours_mysql | 2023-11-07 13:33:57+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
yours_mysql | 2023-11-07 13:33:57+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.44-1.el7 started.
yours_mysql | 2023-11-07 13:33:57+00:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config
yours_mysql | command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.atOD1yOw77
yours_mysql | mysqld: Can't read dir of '/etc/mysql/conf.d/' (Errcode: 13 - Permission denied)
yours_mysql | mysqld: [ERROR] Fatal error in defaults handling. Program aborted!

Resolved on 20231229[Resolved]: Updated the mapping directory for MySQL docker; reinstalled everything. Data Loss (including the shortened link data and access statistics data).

The completed solution is to use the GautamGupta/YOURLS-Import-Export plugin for effortless export and import functionality.

Detailed installation steps:

  1. Download the zip.
  2. Extract the zip.
  3. Place the YOURLS-Import-Export folder in the user/plugins directory.
  4. Activate the plugin.
  5. Restart Docker
    docker-compose -f 'yourls_service.yaml' restart

Experience: Very user-friendly; for example, the current all-link list can be exported (or backed up). In special situations, starting over from scratch (saving time).

Derived Readings: Plugins List: This list of plugins is categorized alphabetically and can be searched for specific functionalities directly on the page.

Next Steps

Feature: Analyze specific user attribute information, such as IP addresses, GEO addresses, similar to the detailed list provided by statcounter.com

yourls-geoip-update

Unable to update the database.
Error downloading “GeoLite2-Country”. Invalid license key.

Do your best; can someone correct this for me?

On 20231216, attempts to update the mmdb database file in the directory ./yourls_data20231120/includes/geo proved ineffective.

  1. Uploaded GeoLite2-City.mmdb
  2. Copied and replaced the original GeoLite2-Country.mmdb
  3. This resulted in two new 64.34MB files, up from the original 5.41MB files
  4. Todo: Observe the changes

On 20231216, practical tests proved that there was no change. Next step:

  1. Download alecthw/mmdb_china_ip_list to obtain the Country.mmdb file
  2. Upload it to ./yourls_data20231120/includes/geo and replace the original GeoLite2-Country.mmdb.
  3. Restart Docker, Todo: Observe the changes.

Advantages and Disadvantages

Advantages of Yourls

Numerous plugins for flexible assembly. Plugin list: YOURLS Awesome List.

Disadvantages of Yourls

The statistical functionality is basic and weak, almost at a comical level.
The documentation is not clear and straightforward. In the case of a failed GeoIP update, how can IP data be manually uploaded to that directory? It is surprising that this information is not easily found through a search engine.


Docker Installation of X-UI

Setting up Xray panel that supports multiple users and protocols on a single port - the ultimate chimera

FranzKafkaYu/x-ui version was used, only needing to modify the above image to enwaiax/x-ui:alpha-zh. As the telegram bot was temporarily not in use, the default was switched back to vaxilu/x-ui

1
2
3
4
5
6
7
8
9
10
version: "3.9"
services:
xui:
image: enwaiax/x-ui
container_name: xui
volumes:
- $PWD/db/:/etc/x-ui/
- $PWD/cert/:/root/cert/
restart: unless-stopped
network_mode: host

A new directory was created, and the above configuration was added to x-ui.yaml
docker-compose -f x-ui.yaml up

https://www.amadues.link/archives/dockerda-jian-jie-dian-vless-ws-tls-web
Following the solution of docker-compose.yaml: https://hostloc.com/thread-1108468-1-1.html
Following the configuration: https://iwanlab.com/npm-xui/
Related video: https://www.youtube.com/watch?v=V3nsDicSMBc

To be tested:
vless://39fde2d2-c88c-4bea-d491-fb6990d49741@vmess.carlzeng.com:17866?type=ws&security=none&path=%2Fgugu#gugugee

On-premises configurations helped in viewing and editing the settings: http://192.168.6.116:54321/fk/xui/
Not successful…awaiting more client connection tests, waiting for rescue.

Potential Resources:

To be continued…