504 Gateway Time-out when using curl on ec2 with Apache and PHP

0

Hi.

I have a ec2 instance (not Lightsail) working behind a Load Balancer. Apache, PHP-FPM are installed and WordPress (or any PHP code) is working mostly fine. However if I try to run code using curl I get a 504 Gateway Timeout. WordPress Site Health also fail because of the same issue.

Issues like:

  • Error: cURL error 28: Failed to connect to fakedomainforthispost.com port 443 after 7503 ms: Connection timed out (http_request_failed)
  • Your site is unable to reach WordPress.org at 198.143.164.251, and returned the error: cURL error 28: Connection timed out after 10001 milliseconds
  • The loopback request to your site failed, this means features relying on them are not currently working as expected. Error: cURL error 28: Failed to connect to fakedomainforthispost.com port 443 after 7503 ms: Connection timed out (http_request_failed)

If I run curl as a command in ssh works fine. If I run curl as code inside a php file I get the 504 Gateway Timeout. I tried setting the KeepAlive rules bigger than the ELB Idle time with no success.

If I clone the ec2 instance and run outside the Load Balancer, curl in php works fine.

The load balancer allows ports 80 and 433 and the connected Target group communicates to the instances using port 80. The rest works fine.

Kind Regards, D.

Deryck
已提問 2 年前檢視次數 1739 次
1 個回答
0

Hi, @Deryck

I think your problem is similar to the next article. Please check the countermeasures.

https://wordpress.org/support/topic/unable-to-connect-to-wordpress-site/

profile picture
專家
iwasa
已回答 2 年前
  • Thanks but does not look like RHEL is the cause. It was already disabled by default in Amazon Linux. Here's the config file.

    # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted

    Thanks again anyway :)

    Do you have another suggestion?

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南