NFS多网站代理访问数据共享案例.png

一、搭建NFS数据共享服务

服务端

# 安装nfs
yum install -y nfs-utils

# 启动nfs
systemctl start nfs-server

# 查看状态
systemctl status rpcbind

# 添加共享网段
cat /etc/exports
  /data 10.0.0.0/24(rw) *

#重启服务
systemctl restart nfs

# 查看
exportfs -v
/data         	10.0.0.0/24(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,root_squash,no_all_squash)
/data         	<world>(sync,wdelay,hide,no_subtree_check,sec=sys,ro,secure,root_squash,no_all_squash)

# 给data目录授权
setfacl -m u:nfsnobody:rwx /data

# 查看
getfacl /data/

客户端

# 安装nfs
yum install nfs-utils -y

# 查看连接(填服务端IP)
showmount -e 10.0.0.13
Export list for 10.0.0.13:
/data (everyone)

# 将服务端/data目录下文件挂载到本机 /apps/nginx/http 目录下
mount 10.0.0.13:/data/ /apps/nginx/http

# 查看	df -h

文件系统                 容量  已用  可用 已用% 挂载点
devtmpfs                 898M     0  898M    0% /dev
tmpfs                    910M     0  910M    0% /dev/shm
tmpfs                    910M  9.6M  901M    2% /run
tmpfs                    910M     0  910M    0% /sys/fs/cgroup
/dev/mapper/centos-root   37G  5.0G   32G   14% /
/dev/sr0                 4.4G  4.4G     0  100% /localrepo
/dev/sda1               1014M  151M  864M   15% /boot
tmpfs                    182M     0  182M    0% /run/user/0
10.0.0.13:/data           37G  5.4G   32G   15% /apps/nginx/html

二、搭建web服务,通过不同的端口访问

1.安装nginx

# 在 /apps/nginx/conf/nginx.conf 文件末尾添加
	include /apps/nginx/conf/conf.d/*.conf;

# 三台机器分别安装nginx
yum install nginx


######   三台web服务分别配置  ######
# 小游戏平台
        location / {
            root   /apps/nginx/html/小游戏平台;
            index  index.html index.htm;
        }

# 运维管理系统
        location / {
            root   /apps/nginx/html/运维管理系统/dashgum/;
            index  index.html index.htm;
        }


# Linux命令手册
        location / {
            root   /apps/nginx/html/Linux命令手册;
            index  index.html index.htm;
        }

# 通过IP地址访问web界面


########## 代理服务器配置 ##########

[root@myx conf.d]# cat web01.conf web02.conf web03.conf 

=======================  web01.conf   =======================

server {
    listen 82;
    server_name localhost;

    location / {
        proxy_pass http://10.0.0.10:80;
	}
}


=======================  web02.conf   =======================


server {
    listen 83;
    server_name localhost;

    location / {
        proxy_pass http://10.0.0.11:80;
        }
}

=======================  web03.conf   =======================

server {
    listen 84;
    server_name localhost;
    location / {
        proxy_pass http://10.0.0.12:80;
        }
}

三、通过网址访问

  • 通过 SwitchHosts 做本地解析

1691587328641.jpg

myx.yx.com 1691587179669.jpg

myx.ht.com

1691587204863.jpg

myx.sc.com

1691587225301.jpg