Can't seem to make auth0 work with AWS ELB instances (nginx)

I’ve got the following code uploaded to an AWS ELB with nginx:

and I can login, logout but the callback fails systematically with the following error message:

Fatal error: Uncaught Auth0\SDK\Exception\StateException: Code exchange was unsuccessful; network error resulted in unfulfilled request in /var/app/current/vendor/auth0/auth0-php/src/Exception/StateException.php:73 Stack trace: #0 /var/app/current/vendor/auth0/auth0-php/src/Auth0.php(305): Auth0\SDK\Exception\StateException::failedCodeExchange() #1 /var/app/current/index.php(61): Auth0\SDK\Auth0->exchange(‘ROUTE_URL_CALLB…’) #2 [internal function]: {closure}() #3 /var/app/current/vendor/steampixel/simple-php-router/src/Steampixel/Route.php(103): call_user_func_array(Object(Closure), Array) #4 /var/app/current/index.php(75): Steampixel\Route::run(‘’) #5 {main} thrown in /var/app/current/vendor/auth0/auth0-php/src/Exception/StateException.php on line 73

You can try at

I think it’s because somehow I cannot figure out how to configure nginx to pass the code and state parameters to the callback route. I tried everything. Here’s the config I have right now:

location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
as per

What do I do? I can’t see any docs to config auth0 properly on AWS ELBs

Ah. Actually, it’s not a problem with nginx I think.

I replaced my callback with this and got the proper parameters!

Route::add(‘/callback’, function() use ($auth0) {
// Have the SDK complete the authentication flow:
echo $_GET[‘code’];
echo " - ";
echo $_GET[‘state’];
// $auth0->exchange(“ROUTE_URL_CALLBACK”);
// Finally, redirect our end user back to the / index route, to display their user profile:
//echo “hello there!”;
// header("Location: " . ROUTE_URL_INDEX);

FWIW, I just checked 3 times my base url, client id, client secret and auth0 domain (I use the client secret as a cookie secret, is that okay?)