#运行用户
#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;
}
}
本文转自 netcorner 博客园博客,原文链接: http://www.cnblogs.com/netcorner/p/7426385.html ,如需转载请自行联系原作者
}