[nginx][tls] nginx配置https与ssl/tls的sni的方法
一 https的sni配置方法
http {
}
server {
listen 443 ssl;
server_name test1.www.local test1.tls.local;
ssl_certificate /root/sni/sni_test1.cer;
ssl_certificate_key /root/sni/sni_test1.key;
location / {
root /data/www;
}
}
server {
listen 443 ssl;
server_name test2.www.local test2.tls.local;
ssl_certificate /root/sni/sni_test2.cer;
ssl_certificate_key /root/sni/sni_test2.key;
location / {
root /data/www;
}
}
server {
listen 443 ssl;
server_name test3.www.local test3.tls.local;
ssl_certificate /root/sni/sni_test3.cer;
ssl_certificate_key /root/sni/sni_test3.key;
location / {
root /data/www;
}
}
}
二 https的sni配置方法
http {
#map \$server_name \$sni_string {
map \$ssl_server_name \$sni_string {
test1.www.local test1;
test2.www.local test2;
test3.www.local test3;
# default xxx;
}
server {
listen 443 ssl;
ssl_certificate /data/sni/sni_\${sni_string}.cer;
ssl_certificate_key /data/sni/sni_\${sni_string}.key;
location / {
root /data/www;
}
}
}
三 tls的sni配置方法
stream {
upstream test {
server 127.0.0.1:50001;
}map \$ssl_server_name \$sni_string {
test1.www.local test1;
test2.www.local test2;
test3.www.local test3;
default test1;
}server {
listen 444 ssl;
ssl_certificate /data/sni/sni_\${sni_string}.cer;
ssl_certificate_key /data/sni/sni_\${sni_string}.key;
proxy_pass test;
}
}
四 复合情况下sni的配置方法
复合情况是指,多个server使用了相同的server name,又需要配置不同的证书文件时。
使用map定义多个不同的变量映射的方法,可以支持多个server的情况,如下,分别定义了两个变量 $sni_string 与 $sni_string445
用来处理不同的server。
stream {
upstream test {
server 127.0.0.1:50001;
}map \$ssl_server_name \$sni_string {
test1.www.local test1;
test2.www.local test2;
test3.www.local test3;
default test1;
}
map \$ssl_server_name \$sni_string445 {
test1.www.local test4451;
test2.www.local test4452;
test3.www.local test4453;
default test4451;
}
server {
listen 444 ssl;
ssl_certificate /data/sni/sni_\${sni_string}.cer;
ssl_certificate_key /data/sni/sni_\${sni_string}.key;
proxy_pass test;
}
server {
listen 445 ssl;
ssl_certificate /data/sni445/sni_\${sni_string445}.cer;
ssl_certificate_key /data/sni445/sni_\${sni_string445}.key;
proxy_pass test;
}
}
[author: classic_tong, date: 20190925]
最新文章
- Git忽略.gitignore规则不生效的解决办法
- python base64的加密与解密
- 通过代码自定义cell(cell的高度不一致)
- session 实现登录功能注意事项
- 一个短小的JS函数,用来得到仅仅包含不重复元素的数组
- java学习___File类的查看和删除
- [C#]6.0新特性浅谈
- tcp netstat用法 TIME_WAIT状态解析 MTU以及MSS
- Java类加载器的工作原理
- 【翻译】使用Sencha Touch开发Google Glass应用程序
- 编程心法 之什么是MVP What is MVP development?
- plus.webview更新上一个页面的信息
- mac 安装protobuf,并编译为java,c++,python
- 【APUE | 03】文件I/O
- Web界面实现数据库增删改查过程
- [视频]K8飞刀 shellcode loader演示教程
- python脚本计算斐波那契数列
- 机器学习实战(一)k-近邻算法
- php常量的实现
- mathematical method
热门文章
- spring cloud Eureka server 问题 Spring Cloud java.lang.TypeNotPresentException
- SDN实验---Ryu的安装
- Java通过行为参数化传递代码
- linux广播
- js scheme 打开手机app的方法
- [LeetCode] 163. Missing Ranges 缺失区间
- LeetCode,3. 无重复字符的最长子串
- .NET(C#)有哪些主流的ORM框架,SqlSugar,Dapper,EF还是...
- 树莓派插入U盘自动拷贝系统日志到U盘或通过U盘升级程序
- spring security实现记住我下次自动登录功能