YOURLS is an URL shortening service [1] and we can deploy a local version of the service to our own VPS. Here, I am using the 1Panel service [2] to set up YOURLS – 1Panel is a web-based Linux system management interface with which we can manage our VPS and set up applications in a very convenient way. The latest version (v1.9.4) of 1Panel does provide YOURLS in its application store and we can install it quickly and easily.

The default github page and the documentation for 1Panel is in Chinese. They should have English support.

Though the installation of YOURLS via 1Panel is made easy, the practical setup does need some care.

  1. We need to specify the external URL in the installation configuration page, as shown below,

    Here, I am using nginx+CloudFlare for setting up the web traffic and the external URL is from the CloudFlare service.

    yourls

  2. We don’t need to expose the port for serving the YOURLS service to public. With CloudFlare, we can assign a sub-domain (e.g., yr.iris-home.net in my case) to the IP address of our VPS. Then, we can configure nginx in the following way to let the external URL redirect to localhost at the port specified for YOURLS,

     server {
             listen 80;
             server_name yr.iris-home.net;
             location / {
                     proxy_pass         http://localhost:40037;
                     proxy_http_version 1.1;
                     proxy_set_header   Upgrade $http_upgrade;
                     proxy_set_header   Connection "upgrade";
                     proxy_set_header   Host $host;
             }
             location /admin {
                     proxy_pass         http://localhost:40037/admin;
                     proxy_http_version 1.1;
                     proxy_set_header   Upgrade $http_upgrade;
                     proxy_set_header   Connection "upgrade";
                     proxy_set_header   Host $host;
             }
     }
    
  3. The following chunk in the nginx configuration is necessary,

     location /admin {
         proxy_pass         http://localhost:40037/admin;
         proxy_http_version 1.1;
         proxy_set_header   Upgrade $http_upgrade;
         proxy_set_header   Connection "upgrade";
         proxy_set_header   Host $host;
     }
    

    as we can only access the YOURLS service via the admin page, meaning that if we visit the domain yr.iris-home.net directly without appending the directory /admin, it will complain about site access forbidden. In practice, we would visit the admin page, add in the URL to be shortened, and then it will go into the database with the shortened URL created.

  4. A curated list of plugins for YOURLS can be found in Ref. [3].

  5. Sometimes, when using the short URL generated via YOURLS, there would be a banner message on the top part of the redirected webpage. This is because we were enabling the toolbar plugin. Refer to Ref. [4] for more information – here, it should be noticed that the plugin mentioned in Ref. [4] is called sample-toobar whereas in the latest version (as of writing the current blog) of YOURLS, the plugin is called YOURLS Toolbar.

References

[1] https://github.com/YOURLS/YOURLS

[2] https://github.com/1Panel-dev/1Panel/tree/dev

[3] https://github.com/YOURLS/awesome?tab=readme-ov-file

[4] https://github.com/orgs/YOURLS/discussions/2988