nginx 1.25.1 发布

nginx 1.25.1 有一个很不错的特性,就是支持了http2 指令,以前这个指令主要是也listen 配置使用的(ssl+http2 场景)
独立指令之后就有了很方便的功能了,比如有些业务希望使用http0.9-1.1 协议,有些需要使用http2,当然目前也是支持了
http3的,可以做到分离,以前版本存在一个问题就是开启了之后协议就都是http2(当然浏览器是可以协商降级的)

参考使用配置

主要是测试

  • docker-compose 文件
 
version: "3"
services:
  app:
     image: nginx:1.25.1-alpine3.17-perl
     volumes:
       - ./nginx.conf:/etc/nginx/nginx.conf
       - ./ssl:/etc/nginx/ssl
     ports:
       - "80:80"
       - "443:443"
  • nignx 配置
user root;  
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  text/html;
    root /usr/share/nginx/html;
    gzip  on;
    resolver 114.114.114.114;
    server {
       listen 80;
       charset utf-8;
       server_name  demoapprong.com;
       default_type text/html;
       location / {
          index index.html index.htm;
       }
    }
    server {
        listen 443 ssl;
        server_name  clouddebug.tech;
        http2 on;
        ssl_certificate      /etc/nginx/ssl/clouddebug.tech.pem;
        ssl_certificate_key  /etc/nginx/ssl/clouddebug.tech.key;
        location / {
            index    index.html index.htm;
        }
    }
    server {
        listen 443 ssl;
        server_name  login.clouddebug.tech;
        http2 off;
        ssl_certificate      /etc/nginx/ssl/login.clouddebug.tech.pem;
        ssl_certificate_key  /etc/nginx/ssl/login.clouddebug.tech.key;
        location / {
            index    index.html index.htm;
        }
    }
}
  • 效果

 

说明

实际上官方commit 上也有说明,可以学习,参考以下信息

参考资料

https://nginx.org/en/CHANGES
https://hg.nginx.org/nginx/rev/08ef02ad5c54

posted on 2023-06-19 19:28  荣锋亮  阅读(513)  评论(0编辑  收藏  举报

导航