🚀 Setting Up Nginx as a Reverse Proxy for OpenMeter
🛠️ Step 1: Install Nginx
First, install Nginx on your server:
sudo apt update && sudo apt install -y nginx
After installation, check if Nginx is running:
sudo systemctl status nginx
If it's not running, start it with:
sudo systemctl start nginx
📜 Step 2: Create a New Nginx Configuration File
We'll set up a new configuration file for OpenMeter.
sudo nano /etc/nginx/sites-available/openmeter
Now, paste the following configuration inside the file:
server {
listen 80;
server_name abc.test.com;
location / {
proxy_pass http://localhost:8888;
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;
}
}
🔹 Explanation:
listen 80;
→ Listens for HTTP traffic on port 80.server_name abc.test.com;
→ Handles requests forabc.test.com
.proxy_pass http://localhost:8888;
→ Forwards requests to OpenMeter running onlocalhost:8888
.proxy_set_header
→ Ensures proper forwarding of client headers.
🔗 Step 3: Enable the Configuration
Create a symbolic link to activate the configuration:
sudo ln -s /etc/nginx/sites-available/openmeter /etc/nginx/sites-enabled/
✅ Step 4: Test & Restart Nginx
Before restarting Nginx, verify the configuration:
sudo nginx -t
If everything is fine, restart Nginx to apply changes:
sudo systemctl restart nginx
🎯 Step 5: Access OpenMeter via the Domain
Now, visiting http://abc.test.com
should proxy requests to OpenMeter running on http://localhost:8888
.
📝 Notes:
- Make sure OpenMeter is running on port
8888
. - If you are using a cloud server, update your DNS settings to point
abc.test.com
to your server's IP. - Consider setting up an SSL certificate with Let's Encrypt (
certbot
) for HTTPS support.
🔥 Now you're all set! Your OpenMeter instance is exposed via Nginx on abc.test.com
. 🚀