使用本文的方案解决网络连通性问题。

  • 网络安全域划分,DBGateway所在环境无法直接连通到阿里云环境(DAS的接入点)。
  • 网络质量问题,DBGateway所在环境与DAS的接入点之间公网质量较差, 但是用户有自己的网络通道,希望DBGateway走内部网络通道连接到Nginx,然后转发到DAS接入点。

Nginx部署方案

wget http://nginx.org/download/nginx-1.17.4.tar.gz
tar -zxvf nginx-1.17.4.tar.gz
cd nginx-1.17.4
# 编译安装,使得Nginx支持stream
./configure --with-http_ssl_module --with-http_v2_module  --with-stream
make
sudo make install
# 默认安装到 /usr/local/nginx/ 下, 新增配置
sudo sh -c bash
cat << EOF >  /usr/local/nginx/conf/hdm-master.conf
worker_processes auto;
events {
    worker_connections  1024;
}
stream {
    upstream backend {
        #  DAS endpoint
        server master-hdm-cn-shenzhen.aliyuncs.com:80            max_fails=3 fail_timeout=30s;
        hash $remote_addr consistent;
    }
    server {
        listen 80;
        # 防止DBGateway获取任务超时,需要7秒以上
        proxy_connect_timeout 10s;
        proxy_timeout 10s;
        proxy_pass backend;
    }
}
EOF
# 运行Nginx
sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/hdm-master.conf