当前位置:Gxlcms > PHP教程 > 基于HTTP的反向代理

基于HTTP的反向代理

时间:2021-07-01 10:21:17 帮助过:65人阅读

一、安装步骤:

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_processes1;
events {
    worker_connections1024;
}

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 {
        server10.100.138.1:8080;
        server10.100.138.2:8080;
    }

    server {
        listen80;
        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_passhttp://baidu;
        }
    }

}

版权声明:本文为博主原创文章,未经博主允许不得转载。

以上就介绍了基于HTTP的反向代理,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

人气教程排行