[root@WEBServer10414 ~]# cat /etc/nginx/nginx.conf
#user nobody;#定義nginx運(yùn)行的用戶(hù)和用戶(hù)組
user root;
worker_processes 8;#nginx進(jìn)程數(shù),建議設(shè)置為等于CPU總核心數(shù)
#error_log logs/error.log;#錯(cuò)誤日志路徑
#error_log logs/error.log notice;#錯(cuò)誤日志類(lèi)型,如[debug | info | notice | warn | error | crit ]
#error_log logs/error.log info;錯(cuò)誤日志類(lèi)型
#pid logs/nginx.pid;#進(jìn)程文件
worker_rlimit_nofile 51200;#一個(gè)nginx進(jìn)程打開(kāi)的最多文件描述符數(shù)目,理論值應(yīng)該是最多打開(kāi)文件數(shù)(系統(tǒng)的值ulimit)
成都創(chuàng)新互聯(lián)專(zhuān)注為客戶(hù)提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于成都網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站、膠州網(wǎng)絡(luò)推廣、重慶小程序開(kāi)發(fā)、膠州網(wǎng)絡(luò)營(yíng)銷(xiāo)、膠州企業(yè)策劃、膠州品牌公關(guān)、搜索引擎seo、人物專(zhuān)訪、企業(yè)宣傳片、企業(yè)代運(yùn)營(yíng)等,從售前售中售后,我們都將竭誠(chéng)為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);成都創(chuàng)新互聯(lián)為所有大學(xué)生創(chuàng)業(yè)者提供膠州建站搭建服務(wù),24小時(shí)服務(wù)熱線:13518219792,官方網(wǎng)址:www.cdcxhl.com
events {#工作模式與連接數(shù)上限
use epoll;#參考事件模型[ kqueue | rtsig | epoll | /dev/poll | select | poll ];
worker_connections 51200;#單個(gè)進(jìn)程最大連接數(shù)
}
http {#設(shè)定http服務(wù)器
include mime.types; #文件擴(kuò)展名與文件類(lèi)型映射表
default_type application/octet-stream; #默認(rèn)文件類(lèi)型
#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;#開(kāi)啟高效文件傳輸模式
#tcp_nopush on;#防止網(wǎng)絡(luò)阻塞
#keepalive_timeout 0;
keepalive_timeout 120;#長(zhǎng)連接超時(shí)時(shí)間,單位是秒
upstream backend {#upstream的負(fù)載均衡,
ip_hash;#使用ip_hash的算法
server 50.50.50.16:8020;#realserver的IP和端口號(hào)
server 50.50.50.13:8020;#realserver的IP和端口號(hào)
}
#gzip on;#開(kāi)啟gzip壓縮輸出
server { #虛擬主機(jī)的配置
listen 8080; #虛擬主機(jī)監(jiān)聽(tīng)的端口號(hào)
server_name WEBServer10414; #虛擬主機(jī)的域名或主機(jī)名
if ( $host ~* "\d+\.\d+\.\d+\.\d+" ) {
return 400;
}
charset utf-8;默認(rèn)編碼
#access_log logs/host.access.log main;#定義本虛擬主機(jī)的訪問(wèn)日志
location / {#對(duì)“/”啟用反向代理
# root html;
index index.jsp index.html index.htm; #可以識(shí)別的索引文件的類(lèi)型
proxy_set_header Host $host:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-Port $remote_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;#后端的Web服務(wù)器可以通過(guò)X-Forwarded-For獲取用戶(hù)真實(shí)IP
proxy_pass http://backend;
proxy_buffer_size 64k;#設(shè)置代理服務(wù)器(nginx)保存用戶(hù)頭信息的緩沖區(qū)大小
proxy_buffers 64 128k;#proxy_buffers緩沖區(qū)
proxy_busy_buffers_size 256k;#高負(fù)荷下緩沖大?。╬roxy_buffers * 2)
proxy_temp_file_write_size 256k;#設(shè)定緩存文件夾大小,將從upstream服務(wù)器傳
}
location /nstatus {#設(shè)定查看nginx狀態(tài)的地址
check_status;
access_log off;
}
#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;
#}
}
upstream backend1 {
ip_hash;
server 50.50.50.16:8030;
server 50.50.50.13:8030;
}
server {
listen 8090;
server_name WEBServer10414;
charset utf-8;
location /stsadmin-cm/ {
index index.jsp index.htm index.html;
proxy_pass http://backend1/stsadmin-cm/;
proxy_redirect default;
proxy_buffer_size 16k;
proxy_buffers 16 128k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
# 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;
# }
#}
}