Answer a question

I keep getting ERR_CONNECTION_REFUSED

worker_processes 4;

events { worker_connections 1024; }

http {

    sendfile off;    

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;


    server {
        listen 80;
        listen [::]:80;
        # server_name _;
        return 301 https://$host$request_uri;
    }


    server {

        listen 443 ssl;
        listen [::]:443 ssl;

        add_header Allow "GET, HEAD" always;

         ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
         ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;


        if ( $request_method !~ ^(GET|HEAD)$ ) {
            return 405;
        }

        return 200;

    }

}

it successfully redirects me from http:localhost to https:localhost, but all I see is this immediately:

enter image description here

Does anyone know why this is happening? is it my certs?

I am just using localhost right now, so it probably isn't firewall thing. Unfortunately, nothing shows up in the access or error logs which is frankly pretty sorry.

Answers

The simple answer was I was using docker, and I needed to open up port 80 AND port 443:

docker run -d -p 80:80 -p 443:443 "$my_image"
Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品

更多推荐