#user nobody;
#处理核数[开启多线程],建议和电脑核数保持一致
worker_processes 8;
#日志存储路径
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#进程号存储的文件路径
#pid logs/nginx.pid;
events {
#并发量配置 总并发量 worker_processes * worker_connections
worker_connections 1024;
}
#配置站点信息的节点
http {
#包含某一个文件
include abc.conf;
#mime.types Nginx所能解析的文件类型
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 65;
#压缩 开启后,用空间换时间,生产环境开启
#gzip on;
#负载均衡池
upstream chenyuanStream {
server 127.0.0.1:18081;
server 127.0.0.1:18082;
server 127.0.0.1:18083;
}
#所有静态页访问
server {
#侦听端口
listen 80;
#当前虚拟机所配置的域名信息[所有该域名访问都遵循该配置规则]
server_name resource.chenyuan.com;
#charset koi8-r;
#access_log logs/host.access.log main;
#针对用户请求路径而言
#位置方位的意思
#根据用户的请求,决定如何路由用户的请求
#/所有请求
location / {
#所有的请求全部到D:\project-chenyuan-portal-fis3-master目录下找对应文件
root D:/project-chenyuan-portal-fis3-master;
}
}
#配置虚拟机 处理www.chenyuan.com
server {
#侦听端口
listen 80;
#当前虚拟机所配置的域名信息[所有该域名访问都遵循该配置规则]
server_name www.chenyuan.com;
#charset koi8-r;
#access_log logs/host.access.log main;
#所有以.jpg,.png。。。都遵循该配置路由规则
location ~ \.(jpg|png|gif|js|css)$ {
#都直接到D盘的images目录找文件
root D:/images;
}
#针对用户请求路径而言
#位置方位的意思
#根据用户的请求,决定如何路由用户的请求
#/所有请求
location / {
#所有www.chenyuan.com的请求都交给chenyuanStream负载均衡池处理
#proxy_pass http://chenyuanStream;
proxy_pass http://127.0.0.1:18081;
}
}
#虚拟机,用于配置某个站点的路由规则
server {
#侦听端口
listen 80;
#当前虚拟机所配置的域名信息[所有该域名访问都遵循该配置规则]
server_name www.so.com;
#charset koi8-r;
#access_log logs/host.access.log main;
#针对用户请求路径而言
#位置方位的意思
#根据用户的请求,决定如何路由用户的请求
#/所有请求
location / {
#root 直接定位到本地目录
root html;
#index 首页
index index.html index.htm;
}
#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
#~:任意字符,不区分大小写
#\.php$以.php结束的请求,遵循下面的配置规则
#location ~ \.php$ {
#所有以php请求的路径,都路由给http://127.0.0.1:80端口处理
# 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;
#}
}
# 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;
# }
#}
}