I have set up an AWS RDS instance and AWS EC2 instance, and I believe I set up the security group to allow both EC2 instance's internal ip and public ip to access the RDS instance. if I ssh to EC2 instance via a ssh client, and type command:
mysql -u xxx -p -h AWS_RDS_endpoint.com
The connection is sucessful. I created test php file named index.php in the EC2 instance web root, code like this:
<?php
$servername = "aws_rds_endpoint.com";
$username = "username";
$password = "password";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
if I type "php index.php" at ssh terminal, it show "Connected successfully", but if at web browser I tried http to EC2 instance like http://xxxx.us-east-2.computer.amazonaws.com ( which is EC2 public DNS), it returns "Connection failed: Permission denied"
Can anyone tell me how to solve this issue?