1

I have nginx with following vhosts:

A gitlab vhost:

server {
    listen 443; 
    server_name gitlab.mydomain.com;     # e.g., server_name source.example.com;
    server_tokens off;     # don't show the version number, a security best practice
    root /home/git/gitlab/public;

    ssl on;
    ssl_certificate /etc/nginx/ssl/gitlab.crt;
    ssl_certificate_key /etc/nginx/ssl/gitlab.key;
    ...
# individual nginx logs for this gitlab vhost
    access_log  /var/log/nginx/gitlab_access.log;
    error_log   /var/log/nginx/gitlab_error.log;
    ...
}

Default vhosts to catch all other domain names

server {
    listen      80;
    return      444;
}

server {
    listen      443;
    return      444;
}

But now if go to gitlab.mydomain.com, I get only

Error 107 (net::ERR_SSL_PROTOCOL_ERROR): SSL protocol error.

Nothing else. And without default rules the gitlab.mydomain.com is also accessible over every *.mydomain.com. This is unacceptable.

How to configure nginx so, that it responds only to the configured names?

1 Answer 1

1

Your default port 443 server doesn't know about any certificate, and hence you're getting this error because it can't do SSL w/o one. Better is to define the ssl* lines in the http section (or every server section that needs SSL) and then have port 443 and ssl on within each server section with the same routing that you're looking for.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .