在软件中,配置Nginx反向代理服务器 IP绑定域名 但不能配置端口号

因为有两个服务器,应该对应两个不同的应用服务器
然后 把 apache-tomcat-7.0.47.tar.gz 通过FileZilla 上传到centOS7中 app目录下
复制两份apache-tomcat-7.0.47
[root@Nigux app]# cp -r apache-tomcat-7.0.47 apache-tomcat-1
[root@Nigux app]# ls
apache-tomcat-1 apache-tomcat-7.0.47 apache-tomcat-7.0.47.tar.gz
[root@Nigux app]# cp -r apache-tomcat-7.0.47 apache-tomcat-2
[root@Nigux app]# ls
apache-tomcat-1 apache-tomcat-2 apache-tomcat-7.0.47 apache-tomcat-7.0.47.tar.gz

然后输入命令 更改一下apache-tomcat-1的端口号修改三个端口号
vim apache-tomcat-1/conf/server.xml



查看apache-tomcat-2端口号
vim apache-tomcat-2/conf/server.xml



然后分别开启两个tomcat
apache-tomcat-1/bin/startup.sh
apache-tomcat-2/bin/startup.sh

然后访问192.168.191.129
关闭防火墙
更改欢迎页,以便区分
[root@Nigux app]# vim apache-tomcat-1/webapps/ROOT/index.jsp
[root@Nigux app]# vim apache-tomcat-2/webapps/ROOT/index.jsp
[root@Nigux app]# cd ../
测试:

http://192.168.191.129:8081/

最后 配置反向代理

如果不配置的话, 我们输入网址,默认跳到的是80端口的nginx页面

upstream fanxiang{
server 192.168.191.129:8080
}
server {
listen 80;
server_name wwww.fanxiang.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://fanxiang;
index index.html index.htm;
}
}
upstream fanxiang1{
server 192.168.191.129:8081
}
server {
listen 80;
server_name wwww.fanxiang.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://fanxiang1;
index index.html index.htm;
}
}
重启加载
找到usr --local--nginx
[root@Nigux nginx]# sbin/nginx -s reload

网友评论