NGINX 400 – the Plain HTTP Request Was Sent to HTTPS Port

This issue is a result of a misconfigured NGINX install. Typically when trying to server HTTP and HTTPS from the same server vhost config.

Commonly it is configured as:

server {
        listen 80;
        listen 443  ssl;
        server_name localhost;
...

But this will result in the 400 error. So the config needs to be changed to:

server {
  listen 80;
  listen 443 default ssl;

  # ssl on   - remember to comment this out
...
}

Then restart nginx and the 400 error should no longer appear.