#運行用戶 #user www-data; #啟動進程,通常設置成和cpu的數量相等 worker_processes 2; #全局錯誤日志及PID文件 error_log logs/error.log; error_log logs/error.log notice; error_log logs/error.log info; #pid logs/nginx.pid; #工作模式及連接數上限 events { #單個后台worker process進程的最大並發鏈接數 worker_connections 1024; } #設定http服務器,利用它的反向代理功能提供負載均衡支持 http { #設定mime類型,類型由mime.type文件定義 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; #sendfile 指令指定 nginx 是否調用 sendfile 函數(zero copy 方式)來輸出文件,對於普通應用,必須設為 on,如果用來進行下載等應用磁盤IO重負載應用,可設置為 off,以平衡磁盤與網絡I/O處理速度,降低系統的uptime. sendfile on; #tcp_nopush on; #連接超時時間 #keepalive_timeout 0; keepalive_timeout 65; #開啟gzip壓縮 gzip on; gzip_disable "MSIE [1-6]\.(?!.*SV1)"; #設定請求緩沖 client_header_buffer_size 1k; large_client_header_buffers 4 4k; ############################################################ # tomcat # listen : localhost:80 # redirect : localhost:81 ############################################################ server{ listen 80; #偵聽端口 server_name 115.55.31.102; #定義使用www.xx.com訪問 #charset koi8-r; access_log logs/localhost81.access.log; #設定本虛擬主機的訪問日志 #默認請求 location / { root /; # 定義服務器的默認網站根目錄位置 index index.aspx; # 定義首頁索引文件的名稱 proxy_pass http://localhost:81 ; #請求轉向mysvr 定義的服務器列表 } #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 /root; } } ############################################################ # Tomcat # listen : ts2121.bdqnbky.com:80 # redirect : ts2121.bdqnbky.com:8080 ############################################################ server { listen 80; #偵聽端口 server_name 115.55.31.102; #定義使用www.xx.com訪問 #charset koi8-r; access_log logs/localhost8080.com.access.log; #設定本虛擬主機的訪問日志 #默認請求 location / { root /; # 定義服務器的默認網站根目錄位置 index index.html; # 定義首頁索引文件的名稱 proxy_pass http://localhost:8080; #請求轉向mysvr 定義的服務器列表 } #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 /root; } # 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; #} } ############################################################ # Tomcat # listen : ts2122.bdqnbky.com:80 # redirect : ts2122.bdqnbky.com:8080 ############################################################ server{ listen 80; #偵聽端口 server_name hh.xx.com; #定義使用www.xx.com訪問 #charset koi8-r; access_log logs/hh.xx.com.access.log; #設定本虛擬主機的訪問日志 #默認請求 location / { root /; # 定義服務器的默認網站根目錄位置 #index index.jsp; # 定義首頁索引文件的名稱 proxy_pass http://hh.xx.com:8081; #請求轉向mysvr 定義的服務器列表 } #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 /root; } } }