The general website is used rsync+inotify enables file synchronization, whileRsync+inotify does not synchronize in two directions, so this time we are going to use the read and write separation. topology: Nginx:192.168.137.50:80
back-end web:apache1:192.168.137.51:80
apache2:192.168.137.52:80
Here we use Nginx as the reverse proxy, using the IFstatements, and$request _method Module for read-write separation,
The configuration is as follows:
server {
Listen 80;
server_name localhost;
#charset Koi8-r;
#access_log Logs/host.access.log Main;
Location/{
Proxy_pass http://192.168.137.51/;
if ($request _method = "PUT") {
Proxy_pass http://192.168.137.52;
}
Index index.html index.htm;
}
when$request _method is put, we forward the request to a write-only web side.
to restart Nginx, use Curl test:
[Email protected] conf]# Curl http://192.168.137.50
[Email protected] conf]# Curl http://192.168.137.50
[Email protected] conf]# Curl http://192.168.137.50
[Email protected] conf]# Curl http://192.168.137.50
the read was forwarded only to the 192.168.137.51 end;
Open the 192.168.137.52-side Apache upload module:
Vim/etc/httpd/conf/httpd.conf
Added under <directory "/var/www/html" >:
DAV on Can
Test:
[Email protected] conf]# curl-t/etc/passwd http://192.168.137.50
<! DOCTYPE HTML PUBLIC "-//ietf//dtd HTML 2.0//en" >
<title>403 forbidden</title>
<p>you don ' t has permission to ACCESS/PASSWD
On this server.</p>
<address>apache/2.2.15 (CentOS) Server at 192.168.137.52 Port 80</address>
</body>
403 occurs because the Apache directory belongs to the group root, so here are the modifications:
Setfacl-m u:apache:rwx/var/www/html/
Test again:
[Email protected] conf]# curl-t/etc/passwd http://192.168.137.50
<! DOCTYPE HTML PUBLIC "-//ietf//dtd HTML 2.0//en" >
<title>201 created</title>
<P>RESOURCE/PASSWD has been created.</p>
<address>apache/2.2.15 (CentOS) Server at 192.168.137.52 Port 80</address>
</body>
and we can see that the file was uploaded to the 192.168.137.52 end.
This article is from the "Linux" blog, so be sure to keep this source http://syklinux.blog.51cto.com/9631548/1837046
Nginx Read-Write separation