How to Install 9Router on a VPS and Use It

How to Install 9Router on a VPS and Use It

If you are used to using AI Agents, you might be familiar with 9Router, an AI proxy router with auto-fallback from expensive providers to free ones. By installing 9Router on a VPS, you can use or access this proxy router from anywhere, on any device.

How to Install 9Router on a VPS with Docker

For installation, you can actually use NPM+PM2 or you can also use Docker. In this tutorial, we will use Docker.

1. Install Docker

First, check whether Docker is already installed or not

docker --version

If it is not installed, you can install it first

curl -fsSL https://get.docker.com | sh

or if you are using RHEL and its derivatives, you can install it with this command

dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repodnf install -y docker-ce docker-ce-cli containerd.iosystemctl enable --now docker
Cara Install 9Router di VPS dan Menggunakannya - WPgan.com - 1

2. Run 9Router in Docker

If Docker is already installed, you can download and run 9Router with Docker

docker run -d \  --name 9router \  -p 20128:20128 \  -v "$HOME/.9router:/app/data" \  -e DATA_DIR=/app/data \  -e JWT_SECRET="ganti-dengan-secret-random-panjang" \  -e INITIAL_PASSWORD="password-dashboard-kamu" \  decolua/9router:latest

Make sure to change replace-with-a-long-random-secret and your-dashboard-password with the key or password you will use later. You must remember this password, as it will be used to log in to the 9Router dashboard.

Cara Install 9Router di VPS dan Menggunakannya - WPgan.com - 2

3. Check Container

Make sure the Docker container is running before you access the 9Router dashboard

docker logs -f 9router

If you are also using a firewall like UFW, make sure to allow the port 20128

ufw allow 20128
Cara Install 9Router di VPS dan Menggunakannya - WPgan.com - 3

For auto-start when the server restarts, you can run this command

docker update --restart unless-stopped 9router

4. Access the 9Router Dashboard

Now you can access the 9Router dashboard. For example, if your server IP is 45.76.180.111, then you can access http://45.76.180.111:20128. If you want to set up access via a domain, you can configure a reverse proxy with Nginx by following this tutorial: How to Configure a Reverse Proxy with Nginx

Cara Install 9Router di VPS dan Menggunakannya - WPgan.com - 4

5. Add an AI Provider

If you have successfully logged in, you can add an AI Provider, for example OpenRouter which provides an API Key with several free models.

To add an AI Provider, you can open the menu Providers > OpenRouter > Add

Cara Install 9Router di VPS dan Menggunakannya - WPgan.com - 5.1

Also, make sure to add an Available model so that the available models can be used

Cara Install 9Router di VPS dan Menggunakannya - WPgan.com - 5.2

6. Create a Combo

To make model selection easier, for example if you have many models, you can create a new Combo, for example with the name wpgan-ai from the menu Combos > Create Combo and add the models you have already added

Cara Install 9Router di VPS dan Menggunakannya - WPgan.com - 6

7. Create an API Key

You can create an API Key from the menu Endpoint > Create Key, where this Key will be used later when you connect 9Router to your application

Cara Install 9Router di VPS dan Menggunakannya - WPgan.com - 7

8. Use 9Router for Coding

Now you can use 9Router for coding. For example, if you use applications like VSCode, Antigravity, JetBrains, Cursor, and the like, you can install the extension cline.

Configure the AI by selecting the option Bring my own API key or BYOK, then configure it like this:

  • API Provider: OpenAI Compatible
  • Base URL: http://45.76.180.111:20128/v1 (change 45.76.180.111 with your server IP address, or domain name if you have already set up a reverse proxy)
  • OpenAI Compatible API Key: The API Key you created in Endpoint
  • Model ID: The name of the combo you created, for example wpgan-ai
Cara Install 9Router di VPS dan Menggunakannya - WPgan.com - 8.1

Once connected, you can try running commands to continue your coding session, or it can also be connected to your applications that require an AI API.

Cara Install 9Router di VPS dan Menggunakannya - WPgan.com - 8.2

That is how to install 9Router on a VPS and how to use it, so that you can later combine various types of AI into one API Key.

Written by

Muhammad Khoirun Nasikin

I enjoy tinkering with WordPress, hosting, VPS, web development, and various small experiments related to websites. I have over 3 years of experience in the web hosting industry.

COMMENTS

Loading...