When you add listeners to a NLB, you specify port and protocols only. Let's say I create a VPC connection to a NLB, of which I have a bunch of different listeners. In the API Gateway integration request I now put in a request using this VPC link, and specify an Endpoint URL
of: http://foobar:yolo/api
.
Is the host of foobar
actually used or could I write anything there? As it is only the http
protocol and the yolo
port which routes the request to the listener. Is the host still important? Or is the host only used if your endpoint would understand tcp
and therefore read the host in the request?
Is the host of foobar actually used or could I write anything there?
Yes, it is used, and you can't write anything. API gateway is going to send your request to the Endpoint URL
you are going to specify. If you specify http://foobar.com/api
your requests will fail. They will only succeed if you actually own a domain foobar.com
that is associated with your NLB.
Thus, if you don't have a domain, you have to use default DNS name
provided for your NLB by AWS:, e.g.:
http://yyyy-fd434e91.elb.us-east-1.amazonaws.com
In contrast, if you own a domain foobar.com
and you want to use http
you are going to use:
http://foobar.com
If you want HTTPS
, and have proper SSL certificate deployed on the NLB along with TLS listener, then you can write:
https://foobar.com
In addition, your application behind the NLB is going to receive the host from Endpoint URL
in a request from the API in a Host
header, e.g.:'
Host: yyyy-fd434e91.elb.us-east-1.amazonaws.com