N
N
nepster-web2016-07-09 02:40:51
Nginx
nepster-web, 2016-07-09 02:40:51

How to configure ssl on subdomains?

There is a bulletin board site. It works on subdomains. One city = 1 subdomain.
For example: msk.site.ru
There is an ssl certificate (https) that works with all subdomains. Everything works, everything is ok.
There is also a redirect from www.*.site.ru to *.site.ru and, accordingly, from http to https.
Recently, a problem has surfaced with addresses like: https://www.msk.site.ru. It shows something like:

Your connection is not secure
The owner of www.msk.site.ru set up his website incorrectly. To protect your information from being stolen, Firefox did not connect to this website.

However, this problem is only with https. That is, www.msk.site.ru will redirect to https://msk.site.ru.
I tried setting the following:
server {
    listen 80;
    server_name *.msk.site.ru;
    return 301 https://msk.site.ru$request_uri;
}


server {
    listen 443;

    ssl on;
    ssl_certificate /home/site/www/prod/ssl-bundle.crt;
    ssl_certificate_key /home/site/www/prod/site.key;

    #enables all versions of TLS, but not SSLv2 or 3 which are weak and now deprecated.
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    server_name *.msk.site.ru;
    return 301 $scheme://msk.site.ru$request_uri;
}

The question is:
How to make a redirect from https://www.*.site.ru to https://*.site.ru ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alegzz, 2016-07-09
@alegzz

you also need to specify the name in the certificate: www.*.site.ru or *.*.site.ru

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question