nginx与consul upsync的安装

一、系统环境
yum install openssh-server
vi /etc/ssh/sshd_config

Port
ListenAddress
PermitRootLogin yes
PasswordAuthentication yes

service sshd start

二、安装nginx

1、下载Nginx

wget http://nginx.org/download/nginx-1.9.10.tar.gz

2、解压Nginx

tar -zxvfnginx-1.9.10.tar.gz

3、配置Nginx

groupadd nginx

useradd -g nginx -s /sbin/nologin nginx

mkdir -p /var/tmp/nginx/client/

mkdir -p /usr/local/nginx
三、安装nginx-upsync-module

1、下载nginx-upsync-module

wget https://github.com/weibocom/nginx-upsync-module/archive/master.zip

下载下来的是master.zip

2、解压nginx-upsync-module(master.zip)

unzip master



yum -y install gcc zlib zlib-devel   pcre pcre-devel openssl openssl-devel

cd nginx-1.9.10

./configure   --prefix=/usr/local/nginx   --user=nginx   --group=nginx   --with-http_ssl_module   --with-http_flv_module   --with-http_stub_status_module   --with-http_gzip_static_module   --with-http_realip_module   --http-client-body-temp-path=/var/tmp/nginx/client/   --http-proxy-temp-path=/var/tmp/nginx/proxy/   --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/   --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi   --http-scgi-temp-path=/var/tmp/nginx/scgi   --with-pcre --add-module=../nginx-upsync-module-master

make && make install
cd /usr/local/nginx/sbin
./nginx
关闭防火墙
/etc/init.d/iptables stop

//nginx安装成功
 访问:http://47.111.162.182

四 安装consul  
wget --no-check-certificate https://releases.hashicorp.com/consul/0.7.5/consul_0.7.5_linux_amd64.zip  
unzip consul_0.7.5_linux_amd64.zip
./consul agent -dev -ui -node=consul-dev -client=172.16.7.82
//在阿里云上开端口
172.16.7.82:8500


五 nginx配置upsync consul
cd /usr/local/nginx/conf/

vi nginx.conf
log_format access_log '$remote_addr - $remote_user [$time_local] "$request" "$request_time" $status $body_bytes_sent "$http_referer" "$http_user_agent" $http_x_forwarded_for';
upstream teacher_api_task_prod {
        server  api.teachertask.yw.yimilan.com;
        upsync 172.16.7.82:8500/v1/kv/upstreams/teacher_api_task_prod upsync_timeout=6m upsync_interval=500ms upsync_type=consul strong_dependency=off;
        upsync_dump_path /root/servers_teacher_api_task_prod.conf;
        server  api.teachertask.yw.yimilan.com backup;
}

server {
        listen   80;

        server_name test.api.teachertask.yw.yimilan.com;
        access_log   /root/teacher_task_accept.log  access_log;
        location / {
                proxy_redirect off;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header REMOTE-HOST $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass http://teacher_api_task_prod;
                proxy_redirect default;
                client_max_body_size    50m;
        }
}

curl -X PUT http://172.16.7.82:8500/v1/kv/upstreams/teacher_api_task_prod/172.16.4.21:8081

文/程忠 浏览次数:0次   2019-09-07 15:49:18

相关阅读


评论:
点击刷新

↓ 广告开始-头部带绿为生活 ↓
↑ 广告结束-尾部支持多点击 ↑