yum install make gcc gcc-c++ libtool zlib zlib-devel
cd /data
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.tar.gz
tar -zxvf pcre-8.21.tar.gz
cd pcre-8.21
./configure
make
make install
cd /data/nginx-1.2.9
./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid
make
make install
参考 http://www.nginx.cn/install
#测试
./sbin/ngnix -t
#启动
/usr/local/nginx/nginx
#重启
./sbin/ngnix -s reload
#查看端口
netstat
-ano | grep 80
#反向代理配置
http://www.ttlsa.com/nginx/use-nginx-proxy/
http{
#...
upstream abc {
server 192.168.1.19:8080 weight=1 max_fails=3 fail_timeout=15s;
}
upstream user {
server 192.168.1.19:8080 weight=1 max_fails=3 fail_timeout=15s;
}
#...
}
server {
listen 80;
server_name a.abc.com;
location ~ {
proxy_pass http://abc;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location ~ ^/user {
proxy_pass http://user;
proxy_set_header X-Forwarded-For $http_clientip;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $http_clientip;
}
}
本文介绍如何在Linux环境下安装Nginx及所需依赖,并详细展示了一个使用Nginx进行反向代理的配置实例,包括负载均衡设置。
2080

被折叠的 条评论
为什么被折叠?



