How to configure nginx configuration if the server one site on https and a few http?

There is one site with https. For such a configuration:

server {
 listen 443;
 server_name domen.ru;

...


server {
 listen 80;
 server_name www.domen.ru domen.ru;
 return 301 https://domen.ru$request_uri;
}

server {
 listen 443;
 server_name www.domen.ru;
 return 301 https://domen.ru$request_uri;
}


And there are several legitimate sites available via http. The problem is that if you request these sites via https then it will open a https site, and no redirect, and the like on the current domain. How to solve the problem?
August 23rd 19 at 10:53
2 answers
August 23rd 19 at 10:55
Since you only have one https site, it is the default one, i.e. handles requests to sites not described by the server. Consequently, in the config of this site do a redirect to https requests on the "left" names on http.
August 23rd 19 at 10:57
For each domain http sites to write out a certificate (otherwise the browsers will complain) and specify https configuration for each of this website in nginx. If you want to redirect a separate server block, if you just want to these sites via https - add listen 443 ssl keys to the old server unit.
No, I need the opposite all the other sites only 80. And the single - 443 - Tressie.Schimmel commented on August 23rd 19 at 11:00
Well then all, as I said, and a separate ssl config with redirect to http version. - enrico.Miller commented on August 23rd 19 at 11:03

Find more questions by tags Nginx