基于Tengine-2.3.3 构建Nacos集群

1,根据Dockerfile生成可运行的Tengine Docker镜像包。
Dockerfile内容如下:

# 建立一个新的镜像文件,配置模板:新建立的镜像是以centos为基础模板
# 因为tengine必须运行在操作系统之上
FROM centos:7.9.2009

# 作者名  作者邮箱
MAINTAINER chinajeckxu <chinajeckxu@163.com>

#安装依赖包
RUN yum -y install net-tools gcc openssl-devel pcre-devel zlib-devel make wget unzip nc tar

# 创建一个新目录来存储nginx文件
RUN mkdir /usr/local/nginx

RUN mkdir /usr/local/nginx/tmp/

RUN mkdir /usr/local/nginx/tmp/proxy

RUN mkdir /usr/local/nginx/tmp/client

RUN mkdir /usr/local/nginx/tmp/fastcgi

RUN mkdir /usr/local/nginx/tmp/uwsgi

RUN mkdir /usr/local/nginx/tmp/scgi

RUN mkdir /tengine

RUN mkdir /tengine/tengine-2.3.3

WORKDIR /tengine

ADD tengine-2.3.3.tar.gz /tengine

WORKDIR /tengine/tengine-2.3.3

RUN ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_addition_module --with-stream --with-stream=dynamic --with-stream_ssl_module --with-stream_realip_module --with-http_dav_module --http-proxy-temp-path=/usr/local/nginx/tmp/proxy --http-client-body-temp-path=/usr/local/nginx/tmp/client --http-fastcgi-temp-path=/usr/local/nginx/tmp/fastcgi --http-uwsgi-temp-path=/usr/local/nginx/tmp/uwsgi --http-scgi-temp-path=/usr/local/nginx/tmp/scgi

RUN make

RUN make install

WORKDIR /usr/local/nginx/sbin

RUN ./nginx -V

RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

VOLUME /tmp 

2,编写Tengine配置文件default.conf。
default.conf 文件内容如下

load_module /usr/local/nginx/modules/ngx_stream_module.so;
events {
    worker_connections  1024;
}
http {
        upstream naocs-http-server  {
                server 192.168.125.243:8851;
                server 192.168.125.243:8853;
                server 192.168.125.243:8855;
        }
        server {
        listen 18848;
                location /nacos/ {
                        proxy_pass http://naocs-http-server;
                }
        }
}
stream {
        upstream naocs-grpc-server-9848  {
                server 192.168.125.243:9851;
                server 192.168.125.243:9853;
                server 192.168.125.243:9855;
        }
        server {
                listen 19848;
                proxy_pass naocs-grpc-server-9848;
        }
        upstream naocs-grpc-server-9849  {
                server 192.168.125.243:9852;
                server 192.168.125.243:9854;
                server 192.168.125.243:9856;
        }
        server {
                listen 19849;
                proxy_pass naocs-grpc-server-9849;
        }
}
上一篇:Spring Cloud Alibaba SideCar【边车模式】【跨斗模式】实际使用


下一篇:面向对象的技术简介