nginx安装与配置3-反向代理两台


1.nginx 反向代理 两台tomcat
2.8080.8081 启动tomcat 记住每个tomcat都有两个端口不要出现tomcat端口占用情况
3.启动项目访问,不报错可以访问
4.在每个tomcat下增加文件夹,然后增加html进行标注
5.http://127.0.0.1:8080/etc80/a.html  

8080

6.http://127.0.0.1:8081/etc81/a.html

8081

7.nginx监听9001端口进行代理 8.nginx配置: server { listen 9001; server_name localhost 127.0.0.1; #charset koi8-r; #access_log logs/host.access.log main; location /etc80/ { proxy_pass http://127.0.0.1:8080; root html; index index.html index.htm; } location /etc81/ { proxy_pass http://127.0.0.1:8081; root html; index index.html index.htm; } 9.http://localhost:9001/etc81/a.html 10.http://localhost:9001/etc80/a.html

location 指令说明
该指令用于匹配 URL。
语法如下:
location [= | ~ |~*| ^~]uri{}

1、= :用于不含正则表达式的 uri 前,要求请求字符串与 uri 严格匹配,如果匹配
成功,就停止继续向下搜索并立即处理该请求。
2、~:用于表示 uri 包含正则表达式,并且区分大小写。
3、~*:用于表示 uri 包含正则表达式,并且不区分大小写。
4、^~:用于不含正则表达式的 uri 前,要求 Nginx 服务器找到标识 uri 和请求字
符串匹配度最高的 location 后,立即使用此 location 处理请求,而不再使用 location
块中的正则 uri 和请求字符串做匹配。
注意:如果 uri 包含正则表达式,则必须要有 ~ 或者 ~* 标识。

细节看这个博客:nginx location指令详解