0x01:根据不同域名判断跳转不同做事
便是根据在nginx.conf配置的server_name与域名或者(或者IP)匹配跳转不同的做事。
#当客户端访问www.domain.com,监听端口号为80,直接跳转到data/www目录下文件server{listen80;server_namewww.domain.com;location/{rootdata/www;indexindex.htmlindex.htm;}}#当客户端访问bbs.domain.com,监听端口号为80,直接跳转到data/bbs目录下文件server{listen80;server_namebbs.domain.com;location/{rootdata/bbs;indexindex.htmlindex.htm;}}

0x02:根据不同端口判断跳转不同做事
便是根据在nginx.conf配置的listen指令匹配跳转不同的做事。
#当客户端访问www.domain.com,监听端口号为8081,直接跳转到data/www目录下文件server{listen8081;server_namewww.domain.com;location/{rootdata/www;indexindex.htmlindex.htm;}}#当客户端访问www.domain.com,监听端口号为8082,直接跳转到data/bbs目录下文件server{listen8082;server_namewww.domain.com;location/{rootdata/bbs;indexindex.htmlindex.htm;}}
0x03:根据链接的ContextPath不同跳转不同的做事器
紧张根据每个运用做事器的ContextPath的普通,匹配跳转到不同的做事器。
#做事创建监听的端口号server{#监听的端口号listen80;#做事名称server_namewww.domain.com;#匹配项目名称为bbs开头location/bbs/{#配置反向代理proxy_passhttp://192.168.1.188:8081/;indexindex.htmlindex.htm;}#匹配项目名称为blog开头location/blog/{#配置反向代理proxy_passhttp://192.168.1.188:8082/;indexindex.htmlindex.htm;}}