环境:开发环境(本地)
nginx基本概念
nginx是什么,有什么用,和tomcat有什么关系,反向代理和正向代理有什么区别
nginx(windows)实现反向代理的流程图
修改hosts文件
在C:\windows\system32\drivers\etc\hosts文件中添加 域名与主机IP 映射
修改nginx配置文件
在nginx-1.12.2\conf\nginx.conf中添加
server {
listen 80;
server_name nongmall.com;
#proxy_set_header Host $host; #告知tomcat此服务的域名,便于tomcat获取
location / {
proxy_pass http://127.0.0.1:8081;
}
}
测试
1.项目部署到tomcat
2.启动 127.0.0.1:8081 端口下的tomcat服务
3.用浏览器访问
可见 域名nongmall.com 访问到了127.0.0.1:8081 端口下的服务