您好,登錄后才能下訂單哦!
[root@WEBServer10414 ~]# cat /etc/nginx/nginx.conf
#user nobody;#定義nginx運行的用戶和用戶組
user root;
worker_processes 8;#nginx進程數,建議設置為等于CPU總核心數
#error_log logs/error.log;#錯誤日志路徑
#error_log logs/error.log notice;#錯誤日志類型,如[debug | info | notice | warn | error | crit ]
#error_log logs/error.log info;錯誤日志類型
#pid logs/nginx.pid;#進程文件
worker_rlimit_nofile 51200;#一個nginx進程打開的最多文件描述符數目,理論值應該是最多打開文件數(系統的值ulimit)
events {#工作模式與連接數上限
use epoll;#參考事件模型[ kqueue | rtsig | epoll | /dev/poll | select | poll ];
worker_connections 51200;#單個進程最大連接數
}
http {#設定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 120;#長連接超時時間,單位是秒
upstream backend {#upstream的負載均衡,
ip_hash;#使用ip_hash的算法
server 50.50.50.16:8020;#realserver的IP和端口號
server 50.50.50.13:8020;#realserver的IP和端口號
}
#gzip on;#開啟gzip壓縮輸出
server { #虛擬主機的配置
listen 8080; #虛擬主機監聽的端口號
server_name WEBServer10414; #虛擬主機的域名或主機名
if ( $host ~* "\d+\.\d+\.\d+\.\d+" ) {
return 400;
}
charset utf-8;默認編碼
#access_log logs/host.access.log main;#定義本虛擬主機的訪問日志
location / {#對“/”啟用反向代理
# root html;
index index.jsp index.html index.htm; #可以識別的索引文件的類型
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服務器可以通過X-Forwarded-For獲取用戶真實IP
proxy_pass http://backend;
proxy_buffer_size 64k;#設置代理服務器(nginx)保存用戶頭信息的緩沖區大小
proxy_buffers 64 128k;#proxy_buffers緩沖區
proxy_busy_buffers_size 256k;#高負荷下緩沖大小(proxy_buffers * 2)
proxy_temp_file_write_size 256k;#設定緩存文件夾大小,將從upstream服務器傳
}
location /nstatus {#設定查看nginx狀態的地址
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;
# }
#}
}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。