最近學習nginx先拿windos練練手,稍微有些積累記錄下
#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;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
upstream a.com {
server 60.205.141.136:8080 weight=1; # 服務器1
server 127.0.0.1:8087 weight=1; #服務器2
}
server {
listen 8077; #監聽端口
server_name a.com
root F:/nginx/nginx/nginx/html;
proxy_redirect off;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.jsp index.html index.htm;
#設置主機頭和客戶端真實地址,以便服務器獲取客戶端真實IP
proxy_set_header Host $host;
#防止ajax安全請求問題
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#禁用緩存
proxy_buffering off;
#設置反向代理的地址
proxy_pass http://a.com;
}
location ~ \.(jsp|jspx|do|action)(\/.*)?$ {
index index.jsp;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://a.com;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
root F:/nginx/nginx/nginx/html;
}
location ~ .*\.(html|js|css|png|gif)$ {
root F:/nginx/nginx/nginx/html;
}
#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;
# }
#}
}
ctive connections: 對後端發起的活動連接數.
Server accepts handled requests: Nginx總共處理了24個連接,成功創建24次握手(證明中間沒有失敗的),總共處理了129個請求.
Reading: Nginx 讀取到客戶端的Header信息數.
Writing: Nginx 返回給客戶端的Header信息數.
Waiting: 開啓keep-alive的情況下,這個值等於 active – (reading + writing),意思就是Nginx已經處理完成,正在等候下一次請求指令的駐留連接.
注意的,本模塊默認是不會編譯進Nginx的,如果你要使用該模塊,則要在編譯安裝Nginx時指定: