nginx – insecure http server is redirecting wrongly to an https server

I’ve got a small website that I’m running on docker, with the ‘dev’ version on port 9090 and the ‘master’ version running on port 8080.

I’m using Nginx on the host (not running on docker) to handle the proxying on port 80/443 for requests coming from the internet.

  • Docker: Dockerize Tomcat application - Best practise
  • How to setup unit test in Docker for nodejs application?
  • Bash multiple port mapping depending on script argument
  • How to run Docker inside Jenkins which is running as container
  • Docker container does not inherit ulimit from host
  • Why mysql backup is not restored into my docker container ?
  • The port 80/443 proxying works perfectly. No problems there.

    Problem: When try and create a server running on port 90 (to show the dev version of the site) which is intended to be insecure, this seems to attempt a redirect back to the SSL version of the site, which is confirmed by the browser redirecting to SSL, and i get an error on the page : ERR_SSL_PROTOCOL_ERROR

    If i comment out the server running on port 80, this problem goes away, but then i lose my port 80 redirects on the live/master site.

    Can anyone see what might be the problem in how i’m setting up the config – thanks! Config below :

    server {
    listen       443 ssl;
        server_name  xxxxxxxxxxxxx.co.uk www.xxxxxxxxxxxxx.co.uk;
        {some ssl config here}
        add_header Strict-Transport-Security max-age=15768000;
    
        location / {
            root   /usr/share/nginx/html;
            index  index.html index.htm;
            auth_basic "Restricted Content";
            auth_basic_user_file /etc/nginx/.htpasswd;
        proxy_pass http://localhost:8080;
        }
    
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
    
    server {
        listen 80;
        server_name xxxxxxxxxxxxx.co.uk www.xxxxxxxxxxxxx.co.uk;
        return 301 https://$host$request_uri;
    }
    
    server {
    listen 90;
    server_name xxxxxxxxxxxxx.co.uk www.xxxxxxxxxxxxx.co.uk;
    
        location / {
            root   /usr/share/nginx/html;
            index  index.html index.htm;
            auth_basic "Restricted Content";
            auth_basic_user_file /etc/nginx/.htpasswd;
        proxy_pass http://localhost:9090;
        proxy_redirect off;
        }
    }
    

  • Searching the Google Container Registry
  • Can't connect to MySQL container on AWS ECS
  • Docker Remote API to login to registry
  • proxypass to phpmyadmin container but got error 502 and Connection refused
  • Port 3306 busy but no process using it
  • Is there a way to set scale value before fig up?
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.