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.

  • Using a any part in external_url causes the server to be unreachable on docker and docker-machine
  • All my docker containers have the error “Too many open files”
  • syntax error in wercker file when using wercker login command
  • Can't Configure Remote Access of Docker Host
  • Move Docker Containers via export/import: lost Configuration like start command
  • How can I use Windows Containers for Software Testing?
  • 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;
        }
    }
    

  • PHP & Docker: script unable to write to /tmp
  • How much maximum heap space does a Play Framework App use per default
  • Docker image tag is not working
  • Restore database with pg_restore in PostgreSQL docker run
  • Why won't my docker-entrypoint.sh execute?
  • Retrieve application config from secure location during task start
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.