A
A
Alexander2016-03-29 01:00:33
Nginx
Alexander, 2016-03-29 01:00:33

How to enable http2 for only one domain?

I have a VPS that hosts several sites on different domains. For one of the domains (let's call it mydomain.ru) I purchased an SSL certificate. Then I decided to enable the http2 protocol for this domain only . I made changes to the nginx configuration corresponding to this domain (added http2 after "listen 443 ssl"):

server {
        listen 443 ssl http2;
        server_name mydomain.ru www.mydomain.ru;
        ...
}

After checking the site at https://tools.keycdn.com/http2-test , I made sure http2 support was enabled. But, then I discovered one unpleasant thing - for some reason, the indicated online tool began to show that all my other domains began to support the http2 protocol (although none of them use the https protocol). How can I make sure that http2 support is only enabled for the right domain? And why is this happening? After all, I only make changes for a single domain - why does this affect all the others?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
Nikon_NLG, 2016-03-29
@summerwind

I understand that you have the only server{} that listens on port 443 - this is your mydomain.ru , so all https requests go to it.

L
littleguga, 2016-03-29
@littleguga

Nikon_NLG is right. Since you have only one domain listening on port 443, requests are wrapped on it. http2-test checks only SSL, since http2 is possible through it, so it writes that other sites are accessible via http2 (although in fact nginx processes requests for mydomain.ru)

Y
Yuri Chudnovsky, 2016-03-29
@Frankenstine

Each ip:port has one web server, which is default, that is, it processes all requests not processed by others. In case you didn't specify it manually, default will be assigned by nginx - the first one in the config. Well, or the only one, if others are not described in the config.
Accordingly, if you want other hits not to get to this site, describe another one as default or create a stub site with your server config.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question