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 ,網關訪問調用 ,下圖通過網關服務調用到會員服務,且爲負載均衡訪問

 

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