您的位置:首页 > 理论基础 > 计算机网络

【Nginx】基于HTTP的反向代理

2015-09-01 18:50 281 查看
一、安装步骤:

cd /app
wget http://nginx.org/download/nginx-1.6.3.tar.gz unzip nginx-1.6.3.tar.gz
cd /app/nginx-1.6.3
./configure
make
make install


二、nginx.conf文件中配置负载均衡

worker_processes  1;
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"';

    upstream baidu {
        server 10.100.138.1:8080;
        server 10.100.138.2:8080;
    }

    server {
        listen  80;
        server_name www.baidu.com;
        access_log /app/nginx/logs/baidu.log main;

        location /  {
            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
            proxy_pass        http://baidu;         }
    }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: