五、Nginx配置实例1-反向代理
Nginx配置实例1-反向代理
1、实现效果
(1)、打开浏览器,在浏览器地址栏输入www.123.com,跳转linux
系统tomcat主页面中。
2、准备工作
(1)、在liunx系统中,安装tomcat,使用默认端口8080;
将tomcat安装包放到linux系统的usr/src目录下,解压
进入tomcat的bin目录,./startup.sh启动tomcat服务器
(2)、对外开放的端口
firewall-cmd--add-port=8080/tcp --permanent
firewall-cmd-reload
查看已经开放的端口号
firewall-cmd --list-all
(3)在window系统中通过浏览器输入地址是否可以正常访问tomcat服务器
3、访问过程分析
4、具体配置
第一步 在window系统的host文件进行域名和IP对应关系的配置
C:\Windows\System32\drivers\etc的host文件中加一行
第二步 在nginx进行请求转发配置
usr/local/nginx/cong/nginx.conf
找到server块
server_name 192.168.17.129;
location /{
root html;
proxy_pass http://127.0.0.1:8080;
index index.html index.htm;
}
5、最终测试
启动nginx
window系统浏览器中输入www.123.com,显示tomcat页面