Reverse proxy service has been more and more widely used in high-load Web sites, often used as Reverse
Proxy includes Squid, Apache, Lighttpd, Nginx, etc. The latter two lightweight applications have quickly occupied a large number of markets because of their excellent performance. This article only discusses the simple applications of the latter two (using proxy to process static files and dynamic The file is handed over to the back-end Web server for processing)
Installation environment
OS: Debian 4.0 r3
Kernel: 2.6.18-6-686
Software List
nginx-0.6.31.tar.gz
lighttpd-1.4.19.tar.gz
Installation Process
Install nginx as a reverse proxy
# tar zxvf nginx-0.6.31.tar.gz
# cd nginx-0.6.31
# ./configure –prefix=/usr/local/nginx
–with-http_realip_module
# make && make install
# vi /usr/local/nginx/conf/nginx.conf
location / {
proxy_pass
http://10.10.10.87/;
proxy_redirect off;
proxy_set_header
Host
$host;
proxy_set_header
X-Real-IP
$remote_addr;
#
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout
90;
proxy_read_timeout
90;
proxy_buffer_size
4k;
proxy_buffers
4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
# Static files
location
location ~*
^.+.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf |js|htm|html)$
{
root /srv/www/htdocs/;
}
start nginx
# /usr/local/nginx/sbin/nginx
Install lighttpd as a reverse proxy
# tar zxvf lighttpd-1.4.19.tar.gz
# cd lighttpd-1.4.19
# ./configure –prefix=/usr/loca/lighttpd –without-bzip2
# make && make install
# cp doc/lighttpd.conf /etc/lighttpd.conf
# vi /etc/lighttpd.conf
server.modules
= (
“mod_access”,
“mod_status”,
“mod_proxy”,
“mod_accesslog”)
server.document-root =
“/srv/www/htdocs/”
server.errorlog
= “/var/log/lighttpd/error.log”
status.status-url = “/server-status”
$HTTP[“url”] !~ “\.(js|css|gif|jpg|png|ico|txt|swf|html|htm)$”
{
proxy.server = ( “” => (
( “host” => “10.10.10.87”, “port” =>
80 )
)
)
}
start lighttpd
# /usr/local/lighttpd/sbin/lighttpd -f /etc/lighttpd.conf