1

I'm new with AWS... I have set up one EC2 instance where it runs Nginx and PHP 7.1.6 i have also made a page that return phpinfo(); details but it returning not my elastic IP but internal IP address:

$_SERVER['SERVER_ADDR'] 172.31.9.228

My EC2 has correctly associated one elastic IP and also trying browsing website everything running smooth.

There is a way to let Nginx returns public IP instead of private one?

2

The EIP is not binded to any network interfaces.

The easiest way to get the EIP is through the instance's metedata.

$eip = file_get_contents('http://169.254.169.254/latest/meta-data/public-ipv4');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.