Express-Gateway is unable to bind to localhost or 127.0.0.1
Calling endpoints directly works as expected:
curl http://localhost:5000/ip
curl http://localhost:5010/erp
Accessing all endpoints via the ExpressGateway on port 5000 works as expected
curl http://localhost:5000/ip
curl http://localhost:5000/api/erp
The issue
The nginx reverse proxy works normally but returns a failed response when accessing the gateway
Cannot GET /api/erp
Binding host: localhost for the http in gateway.config.yml has no effect whatsoever. Even when I change the host to another IP Address and port, the port reflects the change but the IP address of the host remains unchanged as [:::5000] in the express-gateway console.
Please, how can I resolve this?
gateway.config.yml
http:
port: 5000
admin:
port: 9876
host: localhost
apiEndpoints:
api:
host: localhost
paths: '/ip'
erp:
host: localhost
paths: ['/api/erp', '/api/erp/*']
serviceEndpoints:
httpbin:
url: 'https://httpbin.org'
erpService:
url: 'http://localhost:5010'
policies:
- basic-auth
- cors
- expression
- key-auth
- log
- oauth2
- proxy
- rate-limit
pipelines:
default:
apiEndpoints:
- api
policies:
# Uncomment `key-auth:` when instructed to in the Getting Started guide.
# - key-auth:
- proxy:
- action:
serviceEndpoint: httpbin
changeOrigin: true
erpPipeline:
apiEndpoints:
- erp
policies:
# Uncomment `key-auth:` when instructed to in the Getting Started guide.
# - key-auth:
- proxy:
- action:
serviceEndpoint: erpService
changeOrigin: true
The Reverse proxy with Nginx
server {
listen 82;
location / {
proxy_pass http://localhost:5010;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
server {
listen 81;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}