网站首页 > 技术教程 正文
版本支持
目前http2只支持https的网站,openssl版本必须在1.0.2e以上的版本,nginx版本必须在1.9.5版本以上,而且需要编译参数支持:with-http_v2_module、with-http_ssl_module。
openssl
查看openssl版本
openssl version
如果系统默认的openssl版本不够支持,可以直接下载源码,不需要安装,只要在nginx编译的时候,指定到对应的目录。
下载源码
wget -c https://www.openssl.org/source/openssl-1.1.1d.tar.gz
下载PCRE
正则支持,也只是需要源码即可,不需要安装二进制。
wget -c https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
下载Zlib
压缩支持,也只是需要源码即可,不需要安装二进制。
wget -c http://zlib.net/zlib-1.2.11.tar.gz
下载nginx
wget -c http://nginx.org/download/nginx-1.16.1.tar.gz
解压
tar zxvf nginx-1.16.1.tar.gz
tar zxvf zlib-1.2.11.tar.gz
tar zxvf pcre-8.43.tar.gz
tar zxvf openssl-1.1.1d.tar.gz
编译安装
cd nginx-1.16.1
./configure --prefix=/opt/nginx --with-stream --with-mail --with-http_geoip_module --with-http_ssl_module --with-mail_ssl_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-openssl=../openssl-1.1.1d --with-zlib=../zlib-1.2.11 --with-pcre=../pcre-8.43 --with-http_v2_module
make
make install
配置Server
直接在listen配置上加上http2的关键字即可开启。
server {
server_name opcai.top;
listen 443 ssl http2;
#证书(公钥.发送到客户端的)
ssl_certificate /opt/nginx/keys/server.crt;
#私钥,
ssl_certificate_key /opt/nginx/keys/server.key;
access_log logs/opcai.log;
location /static/ {
expires 1d;
alias /data/web/static/;
}
add_header Access-Control-Allow-Headers $http_access_control_request_headers;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://192.168.1.100:8081;
}
}
检查并启动服务
/opt/nginx/sbin/nginx -t
/opt/nginx/sbin/nginx
猜你喜欢
- 2024-10-09 面试题 HTTP及web服务相关(nginx apache)
- 2024-10-09 Nginx实现认证登录(nginx登录验证)
- 2024-10-09 Nginx 是如何处理 HTTP 头部的?(女飞行员余旭遗体头部图)
- 2024-09-08 nginx 安装教程(详解)(nginx安装与配置详解)
- 2024-09-08 学习Nginx,跟着阿里大牛走,一套精心整理的Nginx(PDF文档)
- 2024-09-08 nginx实现内外网访问限制(nginx 内网)
- 2024-09-08 nginx的多域http、https同时访问配置及http重定向https
- 2024-09-08 nginx httpstatus 408 研究(404 not found nginx是什么意思)
- 2024-09-08 Nginx完全指南--内容解析(三)(nginx 详解)
- 2024-09-08 Nginx http 强转https(http://cas.tjgl.teacheredu.cn)
你 发表评论:
欢迎- 最近发表
-
- Win11学院:如何在Windows 11上使用WSL安装Ubuntu
- linux移植(Linux移植freemodbus)
- 独家解读:Win10预览版9879为何无法识别硬盘
- 基于Linux系统的本地Yum源搭建与配置(ISO方式、RPM方式)
- Docker镜像瘦身(docker 减小镜像大小)
- 在linux上安装ollama(linux安装locale)
- 渗透测试系统Kali推出Docker镜像(kali linux渗透测试技术详解pdf)
- Linux环境中部署Harbor私有镜像仓库
- linux之间传文件命令之Rsync傻瓜式教程
- 解决ollama在linux中安装或升级时,通过国内镜像缩短安装时长
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)