Client Access http://bbs.upl.com---resolves to nginx_proxy 172.16.2.8
Nginx_proxy as a reverse proxy to achieve static and dynamic separation:
If it is a known static page request: dispatch to Squid
Picture, text. txt,.html,.htm, client code files. Js,.css
Other unknown requests (including PHP) are dispatched to the LNMP node
Nginx_proxy using a host
BR0 172.16.2.8 <---Analog connection to the public network
VIRBR1 192.168.110.1 <---analog connection to Intranet
LNMP or lamp
Eth0 192.168.110.103
GW 192.168.110.1 Optional
Squid
Eth0 192.168.110.104
GW 192.168.110.1 Optional
First, configure the Nginx_proxy
# yum Install Pcre pcre-devel-y
Nginx-1.0.15.tar.gz
#./configure--prefix=/usr/local/nginx--with-pcre--user=daemon--group=daemon--with-http_stub_status_module
# Make-j4 && make install
To facilitate the execution of this command:
# ln-s/usr/local/nginx/sbin/nginx/usr/local/sbin/
# vim/usr/local/nginx/conf/nginx.conf
User daemon;
Worker_processes 2;
Error_log Logs/error.log;
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;
Keepalive_timeout 65;
Upstream Suqidservs {
Server 192.168.110.104 max_fails=3 fail_timeout=30s;
}
Upstream Lnmpservs {
Server 192.168.110.103 max_fails=3 fail_timeout=30s;
}
server {
Listen 80;
server_name bbs.upl.com upl.com;
Location ~* \. (Gif|bmp|jpeg|jpg|png|css|js|html|htm|txt) $ {
Proxy_pass Http://suqidservs;
Proxy_set_header Host $http _host;
Proxy_set_header X-real-ip $remote _addr;
}
Location/{
Proxy_pass Http://lnmpservs;
Proxy_set_header Host $http _host;
Proxy_set_header X-real-ip $remote _addr;
}
}
}
# Nginx
Ii. Deployment of LNMP nodes
# cat/usr/local/nginx/conf/nginx.conf
User daemon;
Worker_processes 2;
Error_log Logs/error.log;
PID Logs/nginx.pid;
Events {
Worker_connections 1024;
}
HTTP {
Include Mime.types;
Default_type Application/octet-stream;
# changed the fields of the logging client IP
Log_format Main ' $http _x_real_ip-$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;
Keepalive_timeout 65;
....
....
server {
Listen 80;
server_name bbs.upl.com;
Access_log Logs/bbs.access.log Main;
Location/{
root/web/bbs.upl.com/wwwroot/;
Index index.php index.html index.htm;
}
Location ~ \.php$ {
root/web/bbs.upl.com/wwwroot/;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param script_filename $document _root/$fastcgi _script_name;
Include Fastcgi_params;
}
}
....
.....
}
# Nginx
# service MYSQL5 Start
# service PHP-FPM Start
Third, the deployment of squid
As a reverse plus
Speed Agent
Reference Ulp_05.txt
# yum Install Squid-y
Shell> vim/etc/squid/squid.conf
http_access Allow all <---Change the original deny all to allow all
Http_port Accel Vhost Vport <---Modify the parameters of the listening port and set the mode to acceleration mode
Define 192.168.110.104 as the parent node, he is the original node, squid No, can't handle the request to ask it
Cache_peer 192.168.110.103 Parent 0 originserver Name=web1
If squid receives client access requests that use the bbs.upl.com domain name, these requests should be connected to the WEB1 node
Cache_peer_domain Web1 bbs.upl.com
Visible_hostname squid1.upl.com
Cache_dir Ufs/var/spool/squid 20480 16 256
Cache_mem MB
Maximum_object_size_in_memory 2048 KB
Maximum_object_size 102400 KB
Logformat combined%{x-real-ip}>h%ui%un [%tl] "%rm%ru http/%rv"%>hs%<st "%{referer}>h" "%{User-Agent}> H "%ss:%sh
Access_log/var/log/squid/access.log combined
# service Squid start
This article from "Linux" blog, declined reprint!
Using Nginx as agent to realize static and dynamic separation