1. Edit c: \ nginx \ conf \ nginx. conf to add and modify the following content: # user nobody;
Worker_processes 1;
Error_log logs/error. log;
# Error_log logs/error. Log notice;
# Error_log logs/error. Log Info;
PID logs/nginx. PID;
Events {
Worker_connections 64;
}
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;
# Keepalive_timeout 0;
Keepalive_timeout 65;
# Set Request Buffer
Client_header_buffer_size 1 k;
Large_client_header_buffers 4 4 k;
# Enable the gzip Module
Gzip on;
Gzip_min_length 1100;
Gzip_buffers 4 8 k;
Gzip_types text/plain;
Output_buffers 1 32 K;
Post pone_output 1460;
Upstream www.domain1.com {
Server 192.168.30.228: 8001;
}
Upstream www.domain2.com {
Server 192.168.30.221: 8222;
}
Upstream www.domain3.com {
Server 192.168.30.228: 8003;
}
Server {
Listen 80;
Server_name www.domain3.com;
# Charset koi8-r;
Access_log logs/host. access. log main;
Location /{
# Root html;
# Index index.html index.htm; proxy_pass http://www.domain3.com;
Include proxy. conf;
}
}
Server {
Listen 80;
SERVER_NAME www.domain2.com;
# Charset koi8-r;
Access_log logs/host. Access. Log main;
Location /{
# Root HTML;
# Index index.html index.htm;
Proxy_pass http://www.domain2.com;
Include proxy. conf;
}
}
Server {
Listen 80;
SERVER_NAME www.domain1.com;
# Charset koi8-r;
Access_log logs/host. Access. Log main;
Location /{
# Root HTML;
# Index index.html index.htm;
Proxy_pass http://www.domain1.com;
Include proxy. conf;
}
# Location/NginxStatus {
# Stub_status on;
# Access_log on;
# Auth_basic "NginxStatus ";
# Auth_basic_user_file CONF/htpasswd;
#}# Error_page 404/404 .html; # redirect server error pages to the static page/50x.html
#
Error_page 500 502 503 x.html;
Location =/50x.html {
Root HTML;
} # Proxy the PHP scripts to Apache listening on 127.0.0.1: 80
#
# Location ~ \. Php $ {
# Proxy_pass http: // 127.0.0.1;
#}# Pass the PHP scripts to FastCGI server listening on 127.0.0.1: 9000
#
# Location ~ \. Php $ {
# Root html;
# Fastcgi_pass 127.0.0.1: 9000;
# Fastcgi_index index. php;
# Fastcgi_param SCRIPT_FILENAME/scripts $ fastcgi_script_name;
# Include fastcgi_params;
#}# Deny access to. htaccess files, if Apache's document root
# Concurs with nginx's one
#
# Location ~ /\. Ht {
# Deny all;
#}
} # Another virtual host using mix of IP-, name-, and port-based configuration
#
# Server {
# Listen 8000;
# Listen somename: 8080;
# Server_name somename alias another. alias; # location /{
# Root html;
# Index index.html index.htm;
#}
#}
Server {
Listen 8001;
SERVER_NAME www.domain1.com;
Access_log logs/domain1.access. Log main;
Location /{
Index index1.html;
Root/cygdrive/D/html;
}
}
# Server {
# Listen 8002;
# Server_name www.domain2.com;
# Access_log logs/domain2.access. log main;
# Location /{
# Index index2.html;
# Root html;
#}
#}
Server {
Listen 8003;
Server_name www.domain3.com;
Access_log logs/domain3.access. log main;
Location /{
Index index1.html;
Root html;
}
}
} 2.vi 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_max_body_size 10 m;
Client_body_buffer_size 128 K;
Proxy_connect_timeout 90;
Proxy_send_timeout 90;
Proxy_read_timeout 90;
Proxy_buffer_size 4 k;
Proxy_buffers 4 32 k;
Proxy_busy_buffers_size 64 k;
Proxy_temp_file_write_size 64 k;
3. Restart nginx
4. Test: curl-I http://www.domain3.com, http://www.domain3.com, and http://www.domain3.com