模块的中文解释可以看上一个文章: 模块名称含义简介 代理配置 http { // 代理服务器组群, 访问时会会根据使用情况,分配制定的服务器,有减小服务器压力效果 upstream halou{ server 127.0.0.1:7001; server 127.0.0.1:7002; } upstream halou2 { server 127.0.0.1:7003; server 127.0.0.1:7004; } server { listen 80; // 服务默认端口值 server_name localhost; // 访问server名称 location /test.html { root html; // 转发到halou组群, 优先级高于nginx,下面的index不会再执行了 proxy_pass http://halou; index index.html index.htm; } location /test2.html { root html; proxy_pass http://halou2; index index.html index.htm; } } } 浏览器访问 localhost/test.html (访问服务时不写端口,默认就是80)就会被location /test.html匹配中,然后代理到halou组群中的某一个服务上浏览器访问 localhost/test2.html 就会被location /test2.html匹配中,然后代理到halou2组群中的某一个服务上