nginx在windows下的负载均衡
其实一般负载均衡也很少在WINDOWS下来玩吧,只是我最近本机的DEMO需要,所以要找个WINDOWS版本的负载均衡工具来做测试。
先说下载地址,俄文我也看不懂,只能看看版本号。新版的windows下载程序地址:
http://sysoev.ru/nginx/nginx-0.7.63.zip
得到文件
nginx-0.7.63.zip
解开压缩,拷贝到工作目录
双击nginx.exe启动之后,访问http://localhost就能看到nginx的欢迎页面了。
修改conf/nginx.conf配置文件如下:
#user nobody;
worker_processes 2;
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"';
access_log logs/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
#buffer
client_header_buffer_size 1k;
large_client_header_buffers 4 4k;
output_buffers 1 32k;
postpone_output 1460;
#gzip
gzip on;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types text/plain;
upstream easy {
ip_hash;
server localhost:8083;
server localhost:8084;
}
server {
listen 80;
server_name localhost;
charset utf-8;
access_log logs/host.access.log main;
location /nginxstatus {
stub_status on; #nginx status watch
access_log off;
}
location / {
proxy_pass http://easy;
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_max_body_size 10m;
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;
}
}
}
我是比较笨的在WINDOWS进程管理器里面杀掉了nginx的进程(注意哈,有多个启动的进程),重新启动。就可以访问
http://localhost/nginxstatus 查看状态
http://localhost/easylogon等转向到我们的tomcat应用
其实一般负载均衡也很少在WINDOWS下来玩吧,只是我最近本机的DEMO需要,所以要找个WINDOWS版本的负载均衡工具来做测试。
先说下载地址,俄文我也看不懂,只能看看版本号。新版的windows下载程序地址:
http://sysoev.ru/nginx/nginx-0.7.63.zip
得到文件
nginx-0.7.63.zip
解开压缩,拷贝到工作目录
双击nginx.exe启动之后,访问http://localhost就能看到nginx的欢迎页面了。
修改conf/nginx.conf配置文件如下:
#user nobody;
worker_processes 2;
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"';
access_log logs/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
#buffer
client_header_buffer_size 1k;
large_client_header_buffers 4 4k;
output_buffers 1 32k;
postpone_output 1460;
#gzip
gzip on;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types text/plain;
upstream easy {
ip_hash;
server localhost:8083;
server localhost:8084;
}
server {
listen 80;
server_name localhost;
charset utf-8;
access_log logs/host.access.log main;
location /nginxstatus {
stub_status on; #nginx status watch
access_log off;
}
location / {
proxy_pass http://easy;
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_max_body_size 10m;
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;
}
}
}
我是比较笨的在WINDOWS进程管理器里面杀掉了nginx的进程(注意哈,有多个启动的进程),重新启动。就可以访问
http://localhost/nginxstatus 查看状态
http://localhost/easylogon等转向到我们的tomcat应用