Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nginx https not working

Tags:

nginx

https

ssl

I set up a secure connection for my site, but nginx does not redirect https to my instance. When I go to the url https:mydomain.com the nginx shows me Welcome to nginx page.

My nginx config

server {
    listen 80;

    # The host name to respond to
    server_name mydomain.com www.mydomain.com;

    location / {
        # Backend server
        proxy_pass          http://000.000.00.000:8080;
    }
}

##
# SSL Settings
##

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
server {
    listen  443;
    server_name mydomain.com www.mydomain.com;
    ssl on;
    ssl_certificate /root/ssl/mydomain.com/mycert.crt;
    ssl_certificate_key /root/ssl/mydomain.com/private.key;
    ssl_protocols SSLv3 TLSv1;
    ssl_ciphers HIGH:!ADH:!MD5;
    charset utf-8;
    location / {          
            proxy_set_header        Host $host;
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header        X-Forwarded-Proto $scheme;

            proxy_pass          http://000.000.00.000:8080;
            proxy_read_timeout  90;
    }
}
like image 205
user9709261 Avatar asked Oct 16 '25 13:10

user9709261


2 Answers

If your server is in a docker container, maybe you forget to map the port 443 to 443.

-p 443:443
like image 164
Lerner Zhang Avatar answered Oct 19 '25 06:10

Lerner Zhang


Assuming you have no typo in your actual domain name, the configuration looks OK. I would try and test if this piece of configuration is applied at all:

  1. comment out the default server (where the nginx hello page is configured)
  2. Set your server as default by putting default_server at the end of the listen directive.

If you then see a 404, then the part of the config you posted is not loaded at all, maybe you put it in sites-available and forgot to symlink to sites-enabled. Also make sure there is no default_server in the config of the nginx welcome page.

like image 21
Sebastian Freitag Avatar answered Oct 19 '25 06:10

Sebastian Freitag



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!