简体   繁体   中英

503 error when running WordPress on AWS EC2 ELB SSL

I'm just starting with the AWS...

I have 1 EC2 Instance , which is running WordPress (WordPress powered by Bitnami image from the Marketplace - https://aws.amazon.com/marketplace/pp/B007IP8BKQ ). Everything works fine, I can access both front and back-end of the WP installation running from standard HTTP .

The problem starts when I connect the Instance to the ELB and I'm trying to access the site via the HTTPS .

I've run through the process of setting up the SSL certificate using the ACM and applied the cert to the ELB. I've also got the 443 and 80 port enabled on the security group for the EC2 instance. The port forwarding on the ELB is set up for both 443 and 80 to go to 80 and my WP config file is set up to check the H TTP_X_FORWARDED_PROTO header to stop WP getting into an infinite redirect loop.

I think this is all working fine, as I can access the site via the HTTPS and browse the pages. However, when I attempt to log in I am redirected to HTTP and to solve this problem I have set WP site URL and WP home URL to HTTPS. This then results in numerous 503 errors ( 503 Service Unavailable: Back-end server is at capacity ). From the AWS Dashboard, I can see the Instance is running just fine.

I've researched quite a lot to make sure I have everything set up correctly (some threads I've come across - Link 1 Link 2 ) and everything seems fine (but something is obv wrong).

Any suggestions on how to get the ELB to work?

In your .htaccess file in your Wordpress root directory, have you tried to add in

<IfModule mod_setenvif.c>
  SetEnvIf X-Forwarded-Proto "^https$" HTTPS
</IfModule>
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{HTTP:X-Forwarded-Proto} ^http$
  RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>

Also make sure that in your wp_options table that you have siteurl set to https:// and home is set to https://

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM