Nextcloud—Web負載均衡&高可用搭建(三)

目錄:

零、Linux環境準備

一、Nextcloud--數據系統服務器高可用搭建

二、Nextcloud--前端頁面服務器搭建

三、Nextcloud--負載均衡服務搭建

 

拓撲圖如下:

Nextcloud--負載均衡服務搭建

負載均衡是這裏面最簡單配置,可以先去看看nginx官網的文檔,寫的非常明確了。

http://nginx.org/en/docs/http/load_balancing.html

安裝nginx
[root@PROXY ~]# yum -y install epel-release
[root@PROXY ~]# yum -y install nginx

配置nginx
[root@PROXY ~]# vim /etc/nginx/nginx.conf
# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;



# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    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  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    upstream backend{
   	 server  172.24.9.102:80;
   	 server  172.24.9.103:80;
	 ip_hash;
  	 }

    server {
        listen       80;
        server_name  172.24.9.104;

        # Load configuration files for the default server block.

        location / {
	proxy_pass http://backend;
	proxy_set_header Host  $host;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }
}

就這樣完事了,當然如果公司有自己獨立的dns服務器的話,其實不用這臺機器,直接在dns層面做配置就可以了。

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