零、环境

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

 

posted on 2020-01-28 21:46  芒果-Vic  阅读(2995)  评论(0编辑  收藏  举报