1.编辑c:\nginx\conf\nginx.conf
添加以下内容:
#user nobody;
#启动进程
worker_processes 1;
#全局错误日志及PID文件
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
#工作模式及连接数上限
events {
use epoll;
worker_connections 64;
}
#设定http服务器,利用它的反向代理功能提供负载均衡支持
http {
#设定mime类型
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;
#keepalive_timeout 0;
keepalive_timeout 65;
#设定请求缓冲
client_header_buffer_size 1k;
large_client_header_buffers 4 4k;
#开启gzip模块
gzip on;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types text/plain;
output_buffers 1 32k;
postpone_output 1460;
# 设定负载均衡的服务器列表
upstream {
server 127.0.0.1:8001 weight=3;
server 127.0.0.1:8002;
server 127.0.0.1:8003;
}
server {
listen 80;
server_name ;
#charset koi8-r;
access_log logs/host.access.log main;
#对 "/" 启用负载均衡
location / {
#root html;
#index index.html index.htm;
proxy_pass ;
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;
}
server {
listen 8001;
server_name ;
access_log logs/domain1.access.log main;
location / {
index index1.html;
root /cygdrive/D/html;
}
}
server {
listen 8002;
server_name ;
access_log logs/domain2.access.log main;
location / {
index index2.html;
root html;
}
}
server {
listen 8003;
server_name ;
access_log logs/domain3.access.log main;
location / {
index index1.html;
root html;
}
}
#设定查看Nginx状态的地址
#location /NginxStatus {
# stub_status on;
# access_log on;
#auth_basic "NginxStatus";
#auth_basic_user_file conf/htpasswd;
#}
}
2. 访问:
阅读(1373) | 评论(0) | 转发(0) |