81,092
社区成员
发帖
与我相关
我的任务
分享
worker_processes 8;#cpu总线程数
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
upstream 19810109.org {
#ip_hash;
server 19810109.org:8080 weight=1;#tomcat0 port is 8080 权重 1
server 19810109.org:8081 weight=1;#tomcat1 port is 8081 权重 1
}
server {
listen 80;
server_name *.19810109.org;#开启泛域名解析
charset utf-8;
if ($host ~* (.*)\.19810109\.org) {#将头地址存入变量variable
set $variable $1;
}
if ($variable = "") {#如果variable为空则跳转到www.19810109.org
rewrite .* http://www.19810109.org permanent;
}
if ($variable !~* "^www$") {#如果variable不为空且不为www则跳转到http://variable.19810109.org/test.jsp?id=variable
rewrite .* /test.jsp?id=$variable last;
}
location / {
root html;
index index.html index.htm;
proxy_pass http://19810109.org;
proxy_set_header X-Real-IP $remote_addr;
client_max_body_size 100m;
}
location ~ ^/(WEB-INF)/ {
deny all;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}