- https://www.cnblogs.com/ysocean/p/9392908.html
- 反向代理准备工作
- 在linux上已安装完成nginx并能正常启动服务
- 已安装jdk并配置好环境变量
- 安装tomcat
- 查看nginx服务器所在ip地址
ifconfig
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/5cfc990bc0116e61aec3d540ddb6e0a0.png)
- 在服务器上启动tomcat
- 并输入ip地址加8080端口号可以正常访问tomcat欢迎页面
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/1fe0683af3ecefa7de97fa86daa62396.png)
- 编写nginx配置文件
- 修改server_name的值为 服务器ip地址
- 修改proxy_pass 的值为 http://127.0.0.1:8080; 表示通过当访问 http://127.0.0.1:8080 时自动转发到 ;10.8.31.217:80
server {
listen 80;
server_name 10.8.31.217;
location / {
root html;
proxy_pass http://127.0.0.1:8080;
index index.html index.htm;
}
- 在客户机上修改 windows中的hosts文件,配置一个域名映射
C:\Windows\System32\drivers\etc\hosts
10.8.31.217 www.xiemaoshu.com
- 在客户机上访问临时域名,查看能否进入tomcat欢迎页面
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/2922a3a3cf7ac775d647887788d5cda9.png)