码迷,mamicode.com
首页 > 其他好文 > 详细

nginx负载均衡配置

时间:2014-09-17 15:32:43      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:nginx

1、准备工作

nginx-1.6.0.tar.gz

httpd-2.2.23.tar.gz


Director Server:10.0.2.201

Real Server:10.0.2.203

Real Server:10.0.2.204


2、Director Server上配置nginx

# tar zxvf nginx-1.6.0.tar.gz

# cd nginx-1.6.0

# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_gzip_static_module

# make && make install

# vim /usr/local/nginx/conf/nginx.conf

upstream myserver{

server 10.0.2.203:80 weight=1;

server 10.0.2.204:80 weight=1;

ip_hash;

location / {

proxy_pass http://myserver;

proxy_next_upstream http_500 http_502 http_503 error timeout invalid_header;

include /usr/local/nginx/conf/proxy.conf;

# vim /usr/local/nginx/conf/proxy.conf

proxy_redirect off;

proxy_set_header Host $host; #

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

client_body_buffer_size 128k;

proxy_connect_timeout 90;

proxy_send_timeout 90;

proxy_read_timeout 90;

proxy_buffer_size 4k;

proxy_buffers 4 32k;

proxy_busy_buffers_size 64k;

proxy_temp_file_write_size 64k;

# /usr/local/nginx/sbin/nginx 


3、Real Server安装http

# tar zxvf httpd-2.2.23.tar.gz

# cd httpd-2.2.23

# ./configure --prefix=/usr/local/apache2

# make && make install

# cp /usr/local/apache/bin/apachectl /etc/init.d/httpd

# vim /etc/init.d/httpd

修改文件,在文件中‘#!/bin/sh‘后面加入下面两条规则:

#!/bin/sh

#

# chkconfig: 2345 85 15

# description: Apache is a World Wide Web Server

#

# chkconfig --add httpd

# chkconfig --list httpd

# service httpd start


本文出自 “kimileonis” 博客,请务必保留此出处http://kimileonis.blog.51cto.com/5531747/1553640

nginx负载均衡配置

标签:nginx

原文地址:http://kimileonis.blog.51cto.com/5531747/1553640

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!