首页 > 系统相关 >nginx端口复用

nginx端口复用

时间:2022-10-29 13:11:21浏览次数:71  
标签:name ssl 端口 复用 server nginx preread upstream

文档说明:只记录关键地方;

nginx端口例子

使用 $ssl_preread_protocol $ssl_preread_server_name $ssl_preread_alpn_protocols 三个变量的组合,来区分不同的服务


stream {
    log_format main '$remote_addr [$time_local] '
    '$protocol $status $bytes_sent $bytes_received '
    '$session_time "$upstream_addr" '
    '"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';

    access_log      logs/access.log main;
    resolver  223.5.5.5 223.6.6.6 ;

    map $ssl_preread_protocol $upstream_name {
         "TLSv1.3" $name;
          default   https_default;
    }

     
    map "$ssl_preread_server_name$ssl_preread_alpn_protocols" $name {
          default                                     https_default;

          # 例子
          ~http-proxy.xiaoshuogeng.com               sync_chromium; ##
          ~http-proxy.xiaoshuogeng.comh2,http/1.1    https;  ## http 服务

    }

    ## 默认路由配置,全部返回444
    upstream https_default {
        server 127.0.0.1:8443;
    }
    ## 用于同步chromium 源代码
    upstream sync_chromium {
        server 127.0.0.1:8443;
    }
    ## 网页服务
    upstream https {
        server 127.0.0.1:443;
    }


    server {
        listen      443 reuseport;
        proxy_pass  $upstream_name;
        ssl_preread on;
    }

   include /etc/nginx/stream/*.conf;
}



参考文档

  1. nginx 根据服务器名称选择上游 ngx_stream_ssl_preread_module
  2. nginx tcp-udp-load-balancer
  3. nginx http 通用配置
  4. nginx features
  5. nginx documentation
  6. IP Transparency and Direct Server Return with NGINX
  7. iptables四表五链
  8. 四表五链
  9. 过渡到 nftables

实践例子

  1. 快速同步chromium源码以及拉取gcr.io容器镜像
  2. 快速下载chromium源码

标签:name,ssl,端口,复用,server,nginx,preread,upstream
From: https://www.cnblogs.com/jingjingxyk/p/16838523.html

相关文章

  • nginx解决跨域关键点
    文档说明:只记录关键地方;目标:使用CORS和jsonp解决跨域问题一:nginx使用CORS解决跨域涉及到nginx配置也就这些add_headerAccess-Control-Allow-Origin$cors_ori......
  • nginx http 通用配置
    文档说明:只记录关键地方;nginx配置文件nginx.confusernginx;worker_processesauto;worker_cpu_affinityauto;error_log/var/log/nginx/error.logwarn;pid......
  • Centos 修改SSH端口报错:error: Bind to port 27615 on 0.0.0.0 failed: Permission de
    报错截图问题原因selinux问题解决办法修改selinux中的sshd的端口#安装修改工具$yum-yinstallpolicycoreutils-python#查看selinux中的sshd的端口,输出为......
  • 【THM】Nmap Advanced Port Scans(Nmap高级端口扫描)-学习
    本文相关的TryHackMe实验房间链接:https://tryhackme.com/room/nmap03介绍在Nmap基本端口扫描中,我们介绍了TCP标志以及TCP3次握手的过程。要启动TCP连接,首先要给第......
  • nginx root 和 alias 的区别
    区别:alias含有rewrite的意思,可以重写掉不存在的路径。(......
  • linux nginx记录
     安装nginx前首先安装四个依赖包--以下命令一键安装四个依赖 yum-yinstallgcczlibzlib-develpcre-developensslopenssl-devel 创建指定目录下载安装ngi......
  • Istio 使用端口列表
    数据平面端口控制平台端口参考文档https://istio.io/latest/docs/ops/deployment/requirements/#ports-used-by-istio......
  • 新编译安装 NGINX
    2.1安装nginx2.1.1在这个时候我们需要安装依赖包yum-yinstallpcrepcre-devel zlibzlib-devel opensslopenssl-devel2.1.2下载并且解压到(/usr/local/src目录......
  • python - 定时拆分备份 nginx 日志
    python-定时拆分备份nginx日志一、背景:nginx的log不会自动按天备份,而且记录时间格式不统一,此程序专门解决这两个问题;二、windows部署方式1.在nginx目录,创建一个n......
  • 【随手记录】 关于nginx请求500错误 - CreateFile() "/temp/client_body_temp/0000000
    这几天一位前端同事在处理上传请求时候nginx返回500错误,没有额外错误信息,后端也没有接收到请求,看他本地nginx日志错误:[crit]28700#21636:*1389CreateFile()"\nginx-......