Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have configured nginx 1.4.1 to use tls/ssl using a self-signed certificate. I can connect over https using the LAN IP address only. I can also connect to the server_name, but only over http and it only displays the 'Welcome to nginx!' page. Any ideas on how to get https with the server_name? (nginx.conf is just the default.)

$ cat /etc/nginx/sites-available/example.conf

server {
    listen 443 ssl;
    server_name example.com;

    root /srv/web;

    ssl_certificate     /srv/server.crt;
    ssl_certificate_key /srv/server.key;

    ssl_protocols       SSLv3 TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers         RC4:HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;

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

    location / {
        proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://127.0.0.1:8000;
    }

    location ~ /\. {
        deny all;
    }
}

Edit: Would it matter that I'm on someone else's (free/public) subdomain? I know to get a certificate signed by a CA you would need proof of domain ownership, but it shouldn't matter to nginx in my use case, right?

share|improve this question

2 Answers 2

Try adding default_server to the server stanza you showed:

server {
    listen 443 default_server ssl;
    server_name example.com;

    root /srv/web;
    ...

Don't forget to restart.

share|improve this answer
    
Same thing happens. –  ubomb Dec 8 '13 at 15:49

Do you have a symlink in /etc/nginx/sites-enabled to the configuration file in /etc/nginx/sites-available?

nginx only reads configuration files in /etc/nginx/sites-enabled.

share|improve this answer
    
Sure do. To clarify, my configuration was set up without ssl initially which working on the server_name. So I'm thinking it's something with the ssl specific config directives... –  ubomb Dec 9 '13 at 14:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.