I have the following API(s):
- localhost:300/api/customers/
- localhost:400/api/customers/:id/billing
- localhost:500/api/orders
I'd like to use NGINX to have them all run under the following location:
localhost:443/api/
This seems very difficult because of customers spanning two servers.
Here's my failed attempt starting with orders
server {
listen 443;
server_name localhost;
location /api/orders {
proxy_pass https://localhost:500/api/orders;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
server {
listen 443;
server_name localhost;
location /api/customers/$id/billing {
proxy_pass https://localhost:400/api/customers/$id/billing;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
server {
listen 443;
server_name localhost;
location /api/customers {
proxy_pass https://localhost:300/api/customers;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
Anything jump out as far as a fix? Thanks!