Reputation: 86
I'm exploring options to invoke a lambda function via an HTTP call using AWS api gateway. I have an existing Nginx load balancer, serving micro services. When I try to add a location block adding a proxy pass to the aws api gateway,
location /foo {
proxy_pass <aws api gateway url>;
}
this is resolving the hostname to IP eg: 10.20.30.40, but AWS API gateway is returning 400 Bad Request when querying directly from the IP.
Is there any way I can invoke lambda using AWS API gateway from my existing nginx server?
Upvotes: 1
Views: 1078
Reputation: 9020
As you noted, API Gateway will return an error if you try to access by IP. You must configure your proxy to send the Host
header as if you were accessing the API directly. According to the nginx documentation this is achieved via the proxy_pass_header
directive.
Upvotes: 1