当前位置: 动力学知识库 > 问答 > 编程问答 >

amazon web services - 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 HTTP_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 to go to https URL. 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://

分享给朋友:
您可能感兴趣的文章:
随机阅读: