Skip to main content
All CollectionsDomain Setup Guides
How to add Short.io to subpath of existing domain
How to add Short.io to subpath of existing domain
Andy Kostenko avatar
Written by Andy Kostenko
Updated over a week ago

When you want to integrate Short.io for link shortening into a subpath of your existing domain, you can achieve this with a bit of configuration magic involving Nginx. This setup allows you to leverage Short.io’s capabilities without dedicating a full domain or subdomain exclusively to link shortening. Here's a step-by-step guide to get you started.

Step 1: Ensure You Have Nginx

The foundation of this setup is Nginx, a powerful web server that's known for its high performance and dynamic configuration capabilities. You need to have Nginx installed on your server where your main domain is hosted. If Nginx is not installed yet, you can download and install it from the official Nginx website or through your operating system’s package manager.

Step 2: Add Your Domain to Short.io

Before configuring Nginx, make sure your domain is added to your Short.io account. This involves:

  • Logging into your Short.io account.

  • Going to the "Domains" section and clicking on "Add Domain".

  • Entering your existing domain name in the provided field.

This process will ask you to configure your domain using DNS records. You need to ignore these messages

Step 3: Set Up Proxy_Pass on Your Subpath

Now, configure Nginx to proxy requests to Short.io. This is done by editing the Nginx configuration file for your domain, typically located in /etc/nginx/sites-available/yourdomain.conf. You need to add a location block within your server block that looks like this:

location /subpath/ {
proxy_pass https://your-short-domain.short.io;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}

Make sure to replace /subpath/ with the actual subpath you want to use and https://your-short-domain.short.io with your Short.io domain URL. This setup tells Nginx to redirect any requests from your specified subpath to Short.io, seamlessly integrating short link functionality into a part of your existing domain.

Step 4: Ignore Domain Configuration Warning

When you use Short.io in a non-standard way, such as on a subpath, you might encounter a warning in Short.io’s dashboard saying the domain configuration is invalid. This happens because Short.io typically expects the domain to be used at the root level or as a subdomain. Since you are using it at a subpath, this warning can be safely ignored. The proxy setup ensures that the service works as intended, even though the domain is not used in the traditional sense.

Finalizing the Setup

After completing these steps, reload or restart your Nginx server to apply the changes:

sudo systemctl reload nginx

This command makes the new configuration active. You should now be able to use your existing domain with a subpath that redirects to Short.io, effectively using the service for link shortening while maintaining your original site structure and content.

This integration offers a flexible approach to utilizing Short.io’s features without needing additional domains or subdomains, making it an excellent option for those who want to keep their web infrastructure simple yet powerful.

Did this answer your question?