Nginx 设置http1.1和http2

本人目前使用的是nginx 1.17版本,根据实际使用的情况来看。不做任何关于http版本的设置,则默认为http1.1。如果需要开启http2,则按如下设置即可。

server
{
    listen 80;
	listen 443 ssl http2;
    server_name api.xxx.com;
    index index.php index.html index.htm default.php default.htm default.html;
    root /www/wwwroot/xxxx;
    
    # 以下为您的配置
}

如果需要使用http1.1,则删掉配置文件中的http2即可。

需要注意的是:如果服务器上有多个站点,只要有其中一个站点开启了http2,则其他全部默认为http2。

你可能感兴趣的:(服务器)