Error 502 Bad Gateway When Using CodeIgniter
It seems setcookie was being called too much was caused the 502 error. I am not sure if NGNIX was a limit, but this solved the problem.
It's an NGINX/CI problem, if you can't change the settings then changing the session to database worked for me
$config['sess_use_database'] = TRUE;
It could be a buggy Encrypt library. Try setting:
$config[‘sess_encrypt_cookie’] = FALSE;