EasyEngine redirect loop behind AWS ELB/ALB


#1

Hello,

The AWS ALB is listening on HTTPS and passing traffic through to HTTP on an EC2 instance running EasyEngine WordPress.

WordPress is configured with the https:// address and everything seems fine when logged into WordPress, however when a user is logged out they can get redirect issues:

dtbaker@laptop:~$ curl -I https://stylepress.org
HTTP/1.1 301 Moved Permanently
Date: Tue, 14 Mar 2017 14:29:41 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Server: nginx
X-Pingback: http://stylepress.org/xmlrpc.php
Location: https://stylepress.org/
X-Powered-By: EasyEngine 3.7.4
rt-Fastcgi-Cache: HIT

I think Fastcgi is seeing the HTTP connection and attempting to upgrade it to HTTPS or something? And this is cached somewhere?

When I run sudo ee clean on the box it starts working again while logged out. So I don’t know at what point it’s getting stuck in this redirect loop. Here it is working again straight after the ee clean:

dtbaker@laptop:~$ curl -I https://stylepress.org
HTTP/1.1 200 OK
Date: Tue, 14 Mar 2017 14:33:50 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Server: nginx
Vary: Accept-Encoding
X-Pingback: https://stylepress.org/xmlrpc.php
Link: <https://stylepress.org/wp-json/>; rel="https://api.w.org/"
Link: <https://stylepress.org/>; rel=shortlink
X-Powered-By: EasyEngine 3.7.4
rt-Fastcgi-Cache: MISS     <---------------

dtbaker@laptop:~$ curl -I https://stylepress.org
HTTP/1.1 200 OK
Date: Tue, 14 Mar 2017 14:33:56 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Server: nginx
Vary: Accept-Encoding
X-Pingback: https://stylepress.org/xmlrpc.php
Link: <https://stylepress.org/wp-json/>; rel="https://api.w.org/"
Link: <https://stylepress.org/>; rel=shortlink
X-Powered-By: EasyEngine 3.7.4
rt-Fastcgi-Cache: HIT     <---------------

Any ideas?


#2

I think this fixes it in wp-config

if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
       $_SERVER['HTTPS']='on';

it stops wordpress redirecting the http connection to https


#3