Nginx+Zuul实现Zuul网关集群

1.修改host文件 , 并为127.0.0.1 配置域名 www.hbymzsq.com

2.下载安装配置Nginx  地址 http://nginx.org/en/download.html

3.启动nginx后 访问 http://localhost:80  判断是否启动成功

4.修改nginx配置文件,文件地址 nginx包下的conf文件夹下的nginx.conf文件


#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
	upstream backServer{
		server 127.0.0.1:81;
		server 127.0.0.1:82;
		server 127.0.0.1:83;
	}

    server {
        listen       80;
        server_name  www.hbymzsq.com;

        location / {
            proxy_pass   http://backServer/;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        } 
    }
}

5.启动网关服务(eureka注册中心先启动),启动三台网关,分别配置端口号为 81 82  83

6.开启三台member服务,端口分别为8100 8101 8102 ,网关访问调用 ,下图通过网关服务调用到会员服务,且为负载均衡访问

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章