Nginx配置反向代理

客户端:物理机浏览器

Nginx服务器:22.233.23.128 安装nginx

Tomcat服务器:22.233.23.129 安装tomcat

1、tomcat配置

在tomcat/webapps下新建一个test目录,在test目录下将自己的IP写到index.html中

[root@node1 test]# tree /usr/local/src/apache-tomcat-7.0.104/webapps/test/

/usr/local/src/apache-tomcat-7.0.104/webapps/test/

└── index.html

 

0 directories, 1 file

[root@node1 test]# cat index.html

22.233.23.129

测试:

2、nginx反向代理配置

编辑/usr/local/nginx/conf/nginx.conf

监听本机地址22.233.23.128 端口9001

反向代理设置为,http://22.233.23.129:8080/test/index.html

启动nginx服务

[root@localhost ~]# /usr/local/nginx/sbin/nginx

[root@localhost ~]# ps -ef |grep nginx

root 343 1 0 15:24 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx

nobody 344 343 0 15:24 ? 00:00:00 nginx: worker process

root 346 32161 0 15:24 pts/0 00:00:00 grep nginx

3、验证

原文地址:https://www.cnblogs.com/jeancheng/p/13037811.html