Welcome! Log In Create A New Profile

Advanced

How to create Nginx plus REST API UPSTREAM to create server entry with proxy_pass

Posted by johnhaigh 
How to create Nginx plus REST API UPSTREAM to create server entry with proxy_pass
September 03, 2024 08:49PM
Hello,

Using the Nginx plus REST API I want to create the equivalent server entry that will have a server_name with example.somesite.com to do a reverse proxy to http://localhost:3000.

Example manual config:

server {
listen 80;
server_name example.somesite.com;

location / {
proxy_pass http://localhost:3000;
}
}

I have tried doing the following using Nginx plus REST API with a POST to http://localhost:8080/api/9/http/upstreams/vhosts/servers

POST
{
"server": "192.168.86.37:3001",
"route":"example.somesite.com",
"weight": 4,
"max_conns": 0,
"max_fails": 0,
"fail_timeout": "10s",
"slow_start": "10s",
"backup": true,
"down": true
}

It succeeds but I am not sure if this is the right way to implement a proxy pass. I know how to do it manually but translating this to the Nginx plus api is the confusion.

Thank You,

John Haigh



Edited 1 time(s). Last edit at 09/03/2024 08:50PM by johnhaigh.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 123
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready