Nginx:设置为HTTP代理服务器上网,使用upstream

一、配置文件

Nginx作为代理,将请求交给Cache处理,如果Cache没有缓存,就回源。

通过upstream,可以实现多个Cache缓存之间的负载均衡。

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    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;

    upstream my_cache {
        server 192.168.175.130:80;
    }

    server {
        listen       80;
        server_name www.guowenyan.cn;

        location / {
                proxy_set_header Host "www.guowenyan.cn";
                proxy_pass http://my_cache;
        }

    }
}


参考资料:

        Nginx:设置HTTP代理服务器上网:http://blog.csdn.net/guowenyan001/article/details/22718179

        Nginx官网upstream配置实例:https://www.nginx.com/resources/wiki/start/topics/examples/loadbalanceexample/

猜你喜欢

转载自blog.csdn.net/kanguolaikanguolaik/article/details/50316145