• 欢迎访问VPS岛网站,国外VPS,国内VPS,国外服务器,国内服务器,服务器主机,测评及优惠码,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站 QQ群

linux-confd+etcd+nginx+supervisor+docker

Nginx相关 f1yinsky 100次浏览 已收录 0个评论

下载confd

#wget https://github.com/kelseyhightower/confd/releases/download/v0.15.0/confd-0.15.0-linux-amd64
#mv confd-0.15.0-linux-amd64 /usr/bin/confd
#chmod +x /usr/bin/confd

创建confd目录

conf.d 目录中是应用的配置文件定义
templates 目录中是应用的模版文件
confd.toml 是confd本身的配置文件
mkdir -p /etc/confd/{conf.d,templates}

root@747f14c47586:/etc/confd/conf.d# cat nginx.toml 
[template]
src = "nginx.conf.tmpl"
dest = "/etc/nginx/conf.d/default.conf"
keys = [ "/netm/url" ]
check_cmd = "/etc/init.d/nginx configtest"
reload_cmd = "/etc/init.d/nginx reload"

root@747f14c47586:/etc/confd/templates# cat nginx.conf.tmpl 
server {
        listen 80;
        location /netm/index.jsp {
                rewrite ^(.*)$ {{ getv "/netm/url" }} redirect;
                expires 1s;
        }
}

dockfile

FROM centos
MAINTAINER cxiong

# yum
#RUN yum -y update
#RUN yum -y install epel-release
#RUN yum clean all
#RUN yum makecache

#RUN yum -y install iproute

# confd
RUN yum -y install wget

RUN wget https://github.com/kelseyhightower/confd/releases/download/v0.15.0/confd-0.15.0-linux-amd64

RUN mv confd-0.15.0-linux-amd64 /usr/bin/confd
RUN chmod +x /usr/bin/confd
RUN mkdir -p /etc/confd/{conf.d,templates}
COPY nginx.toml /etc/confd/conf.d/
COPY nginx.conf.tmpl /etc/confd/templates/

# nginx 
RUN rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
RUN yum -y install nginx 
RUN sed -i '3a daemon off;' /etc/nginx/nginx.conf
EXPOSE 80

# etcd
#RUN wget https://github.com/coreos/etcd/releases/download/v3.3.9/etcd-v3.3.9-linux-amd64.tar.gz
#RUN tar xzvf etcd-v3.3.9-linux-amd64.tar.gz
#RUN mv etcd-v3.3.9-linux-amd64/etcd* /usr/bin/
#chmod +x /usr/bin/etcd*

RUN yum -y install epel-release
RUN yum -y install etcd
#EXPOSE 2379

# check_netm_url.sh
COPY check_netm_url.sh /
RUN chmod +x /check_netm_url.sh

# supervisor
#RUN yum -y install epel-release
RUN yum -y install supervisor

# cmd 
COPY nginx.ini /etc/supervisord.d/
COPY confd.ini /etc/supervisord.d/
COPY etcd.ini /etc/supervisord.d/
COPY check_netm_url.ini /etc/supervisord.d/

ENTRYPOINT /usr/bin/supervisord -n -c /etc/supervisord.conf
#CMD /usr/bin/supervisord

VPS岛 的文章和资源来自互联网,仅作为参考资料,如果有侵犯版权的资源请尽快联系站长,我们会在24h内删除有争议的资源。丨 转载请注明linux-confd+etcd+nginx+supervisor+docker
喜欢 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址