Anshul Sharma
Anshul Sharma

Reputation: 11

AWS ELB Nginx Remote Address

I am using nginx behind AWS ELB. When i get response from server Remote Address is of ELB not of server is it possible to have server IP instead of AWS ELB.

Upvotes: 1

Views: 485

Answers (3)

Anthony Joseph
Anthony Joseph

Reputation: 275

When the AWS ELB sends requests to an nginx server, it adds a header to the request called "X-Forwarded-For", with the value being the "the IP address of a client when you use an HTTP or HTTPS load balancer"

So your nginx server configuration should contain a line such as:

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

To allow the application that nginx serves to see that header.

Upvotes: 2

Hardik Shah
Hardik Shah

Reputation: 63

You can make change in log format of Nginx and add X-forward, this will print both elb and original WAN ip of the request

Upvotes: -1

Yaron Idan
Yaron Idan

Reputation: 6765

No you can't, if you would that would contradict the whole point of the ELB, and expose you EC2 instance to outside traffic. In that case the ELB won't be able to balance the load on your instance and cause it to crash.

If you want to access your instance IP directly, don't use an ELB.

Upvotes: 1

Related Questions