Remember once Nginx reverse proxy load balancing configuration

Environment: centos6.5

First, edit the installation nginx
http://nginx.org/en/download.html
use Stable version stable version

-prefix = ./configure / usr / local / nginx
vim nginx.conf
main change these places

user daichen; let the child process is to customize the user can not root
worker_processes 4; consistent work processes in general and the number of cpu core

pid logs/nginx.pid;

        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            #root   /home/daichen/web;
            //apache地址
            proxy_pass  http://127.0.0.1:8081;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            index  index.html index.htm;
        }

Second, compile and install the Apache
http://blog.csdn.net/web_orange/article/details/74011343

And ultimately achieve the effect is to visit the nginx server will automatically shift to the apache webserver

Third, a cloned machine as load balancing slave

Arranged at the front upstream server {} [There are many parameters, such as weight machines or the like may alternate weight backup Baidu]

Configuration proxy_pass HTTP: // daichen ; daichen to the back of the upstream custom name

upstream daichen
{
  server 172.16.180.132:80 weight=1;
  server 172.16.180.131:8081 weight=5;
}

server {
    listen       80;]



server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        #root   /home/daichen/web;
        #proxy_pass http://127.0.0.1:8081;
        proxy_pass http://daichen;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header MYNAME daichen;
        index  index.html index.htm;
    }

The basic load balancing on good distribution

Published 65 original articles · won praise 3 · views 50000 +

Guess you like

Origin blog.csdn.net/web_orange/article/details/78670017