zoukankan      html  css  js  c++  java
  • 使用nginx实现基于tcp协议的https协议多域名指向的分别转发功能

    零、环境

    os:centos8 阿里云

    kernel:Linux ${hostname} 4.18.0-80.11.2.el8_0.x86_64 #1 SMP ${time} x86_64 x86_64 x86_64 GNU/Linux

    nginx:nginx-1.17.5

    一、编译安装nginx

    由于nginx插件参数众多,建议编译安装

    安装过程见https://www.cnblogs.com/mangoVic/p/8359864.html

    注意须装插件--with-stream 和 --with-stream_ssl_preread_module


    二、配置

    现有两个不同目的地的https协议的域名,使用一个nginx进行转发,一个域名是xxxxxx.com,另一个是yyyyyy.com

    map $ssl_preread_server_name $backend_pool {
        xxxxxx.com    xxx;
        yyyyyy.com    yyy;
    }
    upstream xxx{
        server xxxxxx.com:443;
    }
    upstream yyy{
        server yyyyyy.com:443;
    }
    server {
        listen 443;
        ssl_preread on;
        resolver 8.8.8.8;
        proxy_pass $backend_pool;
        proxy_connect_timeout 15s;
        proxy_timeout 15s;
        proxy_next_upstream_timeout 15s;
        error_log /var/log/nginx/error-tcp_xxxxxx-yyyyyy.com.log info;
        access_log /var/log/nginx/access-tcp_xxxxxx-yyyyyy.com.log proxy;
    }

    三、格式测试

    nginx -t
    nginx

    四、配置host

    客户端需要将域名指向到转发机

    #vi /etc/hosts
    111.111.111.111 xxxxxx.com
    111.111.111.111 yyyyyy.com

    五、连通性测试

    telnet proxy 443

    六、客户端直接访问域名

    curl https://xxxxxx.com
  • 相关阅读:
    比较好的总结runtime
    开发证书详解
    删除数组中特定元素推荐做法
    pbxproj文件冲突解决办法
    svn不提交user文件
    c提高第六次课 文件读取
    c++函数指针
    c提高第五次作业
    c提高第四次作业
    c提高第四课
  • 原文地址:https://www.cnblogs.com/mangoVic/p/12239044.html
Copyright © 2011-2022 走看看