Knowledgebase

How to Set a Custom Domain for n8n on VPS?

Running automation workflows with n8n on a VPS is powerful, but accessing it via an IP address isn’t very user-friendly. 

Imagine typing a long string of numbers every time you want to open your dashboard! By connecting a custom domain to your n8n instance, you gain a simple, professional, and secure URL, such as https://n8n.yourdomain.com.

In this guide, we will walk you through every step from pointing your domain and setting up Nginx to enabling HTTPS with Let’s Encrypt, so your n8n instance is not only easily accessible but also fully secure. 

Whether you are a beginner or an advanced user, this tutorial ensures you will understand each step clearly.

Let’s get started!

Steps to Set Up a Custom Domain for n8n on Your VPS

Step 1: Point Your Domain to Your VPS

➔ Firstly, log in to your domain registrar’s control panel & Navigate to the DNS management section.

➔ Create an A Record for your subdomain.

For example:

Name

Name

Value

A

n8n.yourdomain.com

<your-server-ip>

➔ Save the changes and wait for the DNS propagation to complete. This can take anywhere from a few minutes to a few hours.

Step 2: Install Nginx and Certbot

Nginx will act as a reverse proxy to forward traffic from your domain to n8n, while Certbot will help you enable HTTPS with Let’s Encrypt certificates.

➔ Connect to your VPS via SSH.

➔ Update your package list and install Nginx and Certbot:

Copied!
sudo apt update
sudo apt install -y nginx certbot python3-certbot-nginx

➔ Enable and start Nginx so it runs automatically on server boot:

Copied!
sudo systemctl enable nginx
sudo systemctl start nginx

Step 3: Configure Nginx as a Reverse Proxy

Nginx will forward requests from your custom domain to the n8n service running on localhost:5678.

Create a new Nginx configuration file for n8n:

Copied!
sudo nano /etc/nginx/sites-available/n8n

➔ You have to paste the following configuration:

Copied!
server {
    listen 80;
    server_name n8n.yourdomain.com;

    location / {
        proxy_pass http://localhost:5678/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

➔ Save the file and exit the editor.

➔ Now, you have to enable the new configuration by creating a symbolic link:

Copied!
sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/

➔ Test the configuration for syntax errors:

Copied!
sudo nginx -t

➔ Restart Nginx to apply the changes:

Copied!
sudo systemctl restart nginx

At this point, your domain should forward traffic to your n8n instance, but it will still use HTTP.

Step 4: Enable HTTPS with Let’s Encrypt

➔ Now, you have to use Certbot to automatically obtain and configure an SSL certificate:

Copied!
sudo certbot –nginx -d n8n.yourdomain.com

➔ You need to follow the prompts to complete the setup. Certbot will automatically modify your Nginx configuration to redirect HTTP to HTTPS.

➔ Set up automatic renewal to ensure your certificate never expires:

Copied!
crontab -e

➔ Add the following line:

Copied!
0 2 * * * certbot renew –quiet –post-hook “systemctl restart nginx”

This cron job will run daily at 2 AM to renew the certificate if needed and restart Nginx.

That’s it! Your n8n dashboard is now accessible via your custom domain:

Copied!
https://n8n.yourdomain.com

You now have a secure, easy-to-remember URL for accessing n8n, and your setup will automatically maintain HTTPS certificates. You can continue building automation workflows while maintaining a secure and professional instance.

n8n self-hosting
Automate Faster Now

Try our ready-to-go n8n self-hosting and start automating in minutes!

Conclusion

Setting up a custom domain for your n8n instance on a VPS not only makes access easier but also gives your workflows a secure and professional environment. Instead of remembering a raw IP address, you can now use a simple HTTPS URL, such as https://n8n.yourdomain.com, with SSL protection in place.

By pointing your domain, configuring Nginx as a reverse proxy, and enabling Let’s Encrypt SSL, you have built a strong foundation for running automation safely and reliably. With automatic certificate renewals, you won’t have to worry about downtime or expired security.

Now, you can focus entirely on what n8n does best—automating tasks and streamlining workflows, while your VPS setup takes care of accessibility and security.