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.

  • Is it possible to show the restart policy of a running Docker container?
  • Access host docker-machine from within container
  • Backup/Restore a dockerized PostgreSQL database
  • Docker bind ports with Go
  • How to prevent access to docker socket form within a container
  • How to get a Docker container's IP address from the host?
  • 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;
        }
    }
    

  • Is it possible change date in docker container?
  • Update existed docker image and all contains once Dockerfile changed
  • How to run multiple times a Docker container with different parameters in Kubernetes?
  • Difference Docker on bare metal and docker on ubuntu
  • ASP.NET Core EF commands: Unable to connect to any of the specified MySQL hosts
  • Running a longer command from docker
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.