码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 系列六、Nginx配置实例之反向代理2


    一、目标

    浏览器网页中访问http://${Linux服务器的IP}:9001/basketball/index.html,浏览器中打印"篮球8080!!!";

    浏览器网页中访问http://${Linux服务器的IP}:9001/football/index.html,浏览器中打印"足球8081!!!";

    二、步骤

    2.1、在/opt/tomcat目录分别创建tomcat8080、tomcat8081文件夹

    1. cd /opt/tomcat
    2. mkdir tomcat8080
    3. mkdir tomcat8081

    2.2、上传apache-tomcat-8.5.63.tar.gz安装包至tomcat8080、tomcat8081文件件

    2.3、tomcat8080配置

    2.3.1、解压

    tar -zxvf apache-tomcat-8.5.63.tar.gz

    2.3.2、在/opt/tomcat/tomcat8080/apache-tomcat-8.5.63/webapps/目录创建basketball文件夹

    1. cd /opt/tomcat/tomcat8080/apache-tomcat-8.5.63/webapps/
    2. mkdir basketball

    2.3.3、上传index.html至basketball文件夹,index.html如下

    1. html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <title>首页title>
    6. head>
    7. <body>
    8. <p style="color: red;font-size: 30px" align="center">篮球8080!!!p>
    9. body>
    10. html>

    2.3.4、启动tomcat8080

    1. /opt/tomcat/tomcat8080/apache-tomcat-8.5.63/bin
    2. ./startup.sh

    2.3.5、测试

    2.4、tomcat8081配置

    2.4.1、解压

    tar -zxvf apache-tomcat-8.5.63.tar.gz

     2.4.2、在/opt/tomcat/tomcat8080/apache-tomcat-8.5.63/webapps/目录创建football文件夹

    1. cd /opt/tomcat/tomcat8080/apache-tomcat-8.5.63/webapps/
    2. mkdir football

    2.4.3、上传index.html至football文件夹,index.html内容如下

    1. html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <title>首页title>
    6. head>
    7. <body>
    8. <p style="color: red;font-size: 30px" align="center">足球8081!!!p>
    9. body>
    10. html>

    2.4.4、修改tomcat8081的端口信息

    1. 修改如下三个端口:
    2. Server port、onnector port、redirectPort

    2.4.5、启动tomcat8081

    1. /opt/tomcat/tomcat8081/apache-tomcat-8.5.63/bin
    2. ./startup.sh

    2.4.6、测试

    2.5、Nginx配置

    1. cd /usr/local/nginx/conf/
    2. vim nginx.conf
    3. # 修改内容如下:
    4. server {
    5. listen 9001;
    6. server_name localhost;
    7. location ~ /basketball/ {
    8. proxy_pass http://127.0.0.1:8080;
    9. }
    10. location ~ /football/ {
    11. proxy_pass http://127.0.0.1:8081;
    12. }
    13. }
    14. # 重新加载nginx配置
    15. ./nginx -s reload

     

    2.6、测试

    1. http://192.168.181.149:9001/basketball/index.html
    2. http://192.168.181.149:9001/football/index.html

     

  • 相关阅读:
    antv G6在vue项目中的实践总结
    用go封装一下二级认证功能
    web前端期末大作业:基于html化妆品购物商城项目的设计与实现——化妆品官方网站设计与实现(HTML+CSS+JS)
    Fullcalendar(简单的日程管理)
    Unity技术手册 - 生命周期旋转RotationOverLifetime-速度旋转RotationBySpeed-外力ExternalForces
    安卓核心板开发板的操作系统版本有哪些?
    HTTP请求头
    c语言编程文件的输入输出函数
    阿里老哥独家珍藏的Java面试突击宝典,轻松应对95%秋招面试题
    vue之封装tab类组件
  • 原文地址:https://blog.csdn.net/HelloWorld20161112/article/details/132805382
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号