【发布时间】:2017-02-07 18:13:39
【问题描述】:
我有以下 API:
- localhost:300/api/customers/
- localhost:400/api/customers/:id/billing
- localhost:500/api/orders
我想使用 NGINX 让它们都在以下位置运行:
本地主机:443/api/
这似乎很困难,因为客户跨越两台服务器。
这是我从订单开始的失败尝试
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;
}
}
有什么可以解决的吗?谢谢!
【问题讨论】:
标签: api nginx port reverse-proxy