#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
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 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
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
#
#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;
#}
}
# 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;
# }
#}
#配置Tomcat集群
#默认负载均衡策略:采用轮询机制
#weight权重 越大分配的访问量越大
#down 下线
#backup 当其他都不正常时在启用带有此标注的服务器
#max_fails=1 最大失败次数,当检查服务器是否正常时,如果检查失败的次数达到规定的次数时,则断定该服务#器故障,在规定时间内,不会再将请求发往该机器
#fail_timeout=60s 60秒过后会再次检测.正常再次启用该服务器
#
upstream demo {
#Linux 中Tomcat的负载均衡
#server 192.168.65.132:8091 weight=6 max_fails=1 fail_timeout=60s;
#server 192.168.65.132:8092 weight=3 max_fails=1 fail_timeout=60s;
#server 192.168.65.132:8093 weight=1 backup;
}
#配置后台管理服务器
server{
listen 80;
server_name manage.demo.com;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location / {
#反向代理到具体url
proxy_pass http://demo;
proxy_connect_timeout 5; #连接超时时间
proxy_read_timeout 5; #读取超时时间
proxy_send_timeout 5; #发送超时时间
}
}
#配置前台服务
server {
listen 80;
server_name www.demo.com;
location /{
proxy_pass http://localhost:8092;
}
}
#配置sso登陆
server {
listen 80;
server_name sso.demo.com;
#server_name manage.jt.com;
location /{
proxy_pass http://localhost:8093;
}
}
#配置购物车
server {
listen 80;
server_name cart.demo.com;
location /{
proxy_pass http://localhost:8094;
}
}
#配置订单系统
server {
listen 80;
server_name order.demo.com;
location /{
proxy_pass http://localhost:8095;
}
}
#配置全文检索系统
server {
listen 80;
server_name solr.demo.com;
location /{
proxy_pass http://192.168.65.141:8983;
}
}
}