Beta version nginx1.6.3
Test System: CentOS 6 System
Installation Configuration document: http://jasonzhu.blog.51cto.com/5594807/1750188
Principle:
The user makes the access request, the domain name resolves to the nginx server's IP (23.234.xx.2), configures the IP reverse proxy in the Nginx server, will xx.2 receives the request, through the proxy forwarding rule, all transfers to 23.234.xx.3
User---(Request, domain name resolution IP)---> Anti-attack (nginx forwarding server)---(proxy forwarding rule)---backend Apache server
IP Reverse proxy configuration:
Vim/usr/local/nginx/conf/nginx.conf
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;
include/usr/local/nginx/conf/conf.d/*.conf;
server {
Listen 80;
server_name _;
#charset Koi8-r;
#access_log Logs/host.access.log Main;
Location/{
Proxy_next_upstream http_502 http_504 error timeout invalid_header;
Proxy_pass http:/$target;
Proxy_set_header Host $host;
Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
}
#error_page 404/404.html;
# REDIRECT Server error pages to the static page/50x.html
#
Error_page 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}
}
Create conf.d/map.conf extended forwarding rules under the/usr/local/nginx/conf/directory
Vim/usr/local/nginx/conf/conf.d/map.conf
Map $server _addr $target {
#baidu. com
23.234.xx.2 23.234.xx.3:80;
#请求IP Forwarding IP: Port
}
The Ps:target parameter is passed to the nginx.conf configuration file as the address of the next hop forwarding.
/usr/local/nginx/sbin/nginx-s Reload Reload configuration file
Nginx Reverse proxy configuration