多if
server 80 里添加rewrite ^(.*)host$1 permanent;
即:
server {
listen 80;
server_name test.beeae.com;
autoindex on;
sendfile on;
tcp_nopush on;
set $flag '';
if ($host = 'www.demo.kediantong.com'){
set $flag 1;
}
if ($host = 'baealloc.demo.kediantong.com'){
set $flag 1;
}
if ($host = 'baeimage.demo.kediantong.com'){
set $flag 1;
}
if ($host = 'baefile.demo.kediantong.com'){
set $flag 1;
}
if ($host = 'baeconfig.demo.kediantong.com'){
set $flag 1;
}
if ($host = 'baerpcserver.demo.kediantong.com'){
set $flag 1;
}
if ($host = 'api.demo.kediantong.com'){
set $flag 1;
}
if ($host = 'ac01.demo.kediantong.com'){
set $flag 1;
}
if ($host = 'ic01.demo.kediantong.com'){
set $flag 1;
}
if ($host = 'sysmanage.demo.kediantong.com'){
set $flag 1;
}
if ($flag != 1){
rewrite ^(.*)host$1 permanent;
}
location / {
root /data/clients;
autoindex on;
sendfile on;
tcp_nopush on;
}
}
server {
listen 443 ssl;
ssl_certificate /data/nginxhttps/server.crt;
ssl_certificate_key /data/nginxhttps/server.key;
server_name test.beeae.com;
autoindex on;
sendfile on;
tcp_nopush on;
location / {
root /data/clients;
autoindex on;
sendfile on;
tcp_nopush on;
}
}