Nginx配置
1 #user nobody; 2 worker_processes 1; 3 4 #error_log logs/error.log; 5 #error_log logs/error.log notice; 6 #error_log logs/error.log info; 7 8 #pid logs/nginx.pid; 9 10 11 events { 12 worker_connections 1024; 13 } 14 15 16 http { 17 include mime.types; 18 default_type application/octet-stream; 19 20 #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 21 # '$status $body_bytes_sent "$http_referer" ' 22 # '"$http_user_agent" "$http_x_forwarded_for"'; 23 24 #access_log logs/access.log main; 25 31 32 sendfile on; 33 #tcp_nopush on; 34 35 #keepalive_timeout 0; 36 keepalive_timeout 65; 37 38 #gzip on; 39 40 server { 41 listen 80; 42 server_name localhost; 43 44 #charset koi8-r; 45 46 #access_log logs/host.access.log main; 47 48 location / { 49 root html; 50 index index.html index.htm;
proxy_pass http://localhost; #HTTP转发或处理
52 } 53 54 #error_page 404 /404.html; 55 56 # redirect server error pages to the static page /50x.html 57 # 58 error_page 500 502 503 504 /50x.html; 59 location = /50x.html { 60 root html; 61 } 62 63 # proxy the PHP scripts to Apache listening on 127.0.0.1:80 64 # 65 #location ~ \.php$ { 66 # proxy_pass http://127.0.0.1; 67 #} 68 69 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 70 # 71 #location ~ \.php$ { 72 # root html; 73 # fastcgi_pass 127.0.0.1:9000; 74 # fastcgi_index index.php; 75 # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; 76 # include fastcgi_params; 77 #} 78 79 # deny access to .htaccess files, if Apache's document root 80 # concurs with nginx's one 81 # 82 #location ~ /\.ht { 83 # deny all; 84 #} 85 } 86 87 88 # another virtual host using mix of IP-, name-, and port-based configuration 89 # 90 #server { 91 # listen 8000; 92 # listen somename:8080; 93 # server_name somename alias another.alias; 94 95 # location / { 96 # root html; 97 # index index.html index.htm; 98 # } 99 #} 100 101 102 # HTTPS server 103 # 104 #server { 105 # listen 443 ssl; 106 # server_name localhost; 107 108 # ssl_certificate cert.pem; 109 # ssl_certificate_key cert.key; 110 111 # ssl_session_cache shared:SSL:1m; 112 # ssl_session_timeout 5m; 113 114 # ssl_ciphers HIGH:!aNULL:!MD5; 115 # ssl_prefer_server_ciphers on; 116 117 # location / { 118 # root html; 119 # index index.html index.htm; 120 # } 121 #} 122 123 } 124 125 #TCP、WCF负载均衡 139 stream { 140 upstream wcf_backend { 141 server IP1:PORT max_fails=2 fail_timeout=5s; 142 server IP2:PORT max_fails=2 fail_timeout=5s;144 } 145 server { 146 listen port;#端口可与实际一致 147 148 proxy_pass wcf_backend; 149 } 150 upstream tcp_backend {
141 server IP1:PORT max_fails=2 fail_timeout=5s;
142 server IP2:PORT max_fails=2 fail_timeout=5s;
144 }
145 server {
146 listen port;#端口可与实际一致
147
148 proxy_pass tcp_backend;
149 }
160 161 }
#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 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;
#WCF负载均衡 #upstream CPEC1PMESMI005V {#server 10.202.12.128:8007 max_fails=2 fail_timeout=5s;#server 10.202.12.129:8007 max_fails=2 fail_timeout=5s; #}
sendfile on; #tcp_nopush on;
#keepalive_timeout 0; keepalive_timeout 65;
#gzip on;
server { listen 80; server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / { root html; index index.html index.htm; #proxy_pass http://CPEC1PMESMI005V }
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.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; # } #}
# HTTPS server # #server { # listen 443 ssl; # server_name localhost;
# ssl_certificate cert.pem; # ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on;
# location / { # root html; # index index.html index.htm; # } #}
}
#TCP负载均衡#stream { #upstream cache_backend { #server 10.202.12.128:9002 max_fails=2 fail_timeout=5s; #server 10.202.12.129:9002 max_fails=2 fail_timeout=5s; #server 10.202.12.127:9002 max_fails=2 fail_timeout=5s; #} #server { #listen 9002; #proxy_pass cache_backend; #}#}
stream { upstream wcf_backend { server 10.202.12.128:8007 max_fails=2 fail_timeout=5s; server 10.202.12.129:8007 max_fails=2 fail_timeout=5s; #server 10.202.12.127:8007 max_fails=2 fail_timeout=5s; } server { listen 8007; proxy_pass wcf_backend; } upstream tcp_backend { server 10.202.12.128:9002 max_fails=2 fail_timeout=5s; server 10.202.12.129:9002 max_fails=2 fail_timeout=5s; server 10.202.12.127:9002 max_fails=2 fail_timeout=5s; } server { listen 9002; proxy_pass tcp_backend; }
}