扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
[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)
成都创新互联专注为客户提供全方位的互联网综合服务,包含不限于成都网站设计、成都做网站、胶州网络推广、重庆小程序开发、胶州网络营销、胶州企业策划、胶州品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;成都创新互联为所有大学生创业者提供胶州建站搭建服务,24小时服务热线:13518219792,官方网址:www.cdcxhl.com
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;
# }
#}
}
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流