当前位置: 首页 > article >正文

【Docker】05-Docker部署前端项目

1. nginx.conf


worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/json;

    sendfile        on;
    
    keepalive_timeout  65;

    server {
        listen       18080;
        # 指定前端项目所在的位置
        location / {
            root /usr/share/nginx/html/hmall-portal;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        location /api {
            rewrite /api/(.*)  /$1 break;
            proxy_pass http://hm:8080;
        }
    }
    server {
        listen       18081;
        # 指定前端项目所在的位置
        location / {
            root /usr/share/nginx/html/hmall-admin;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        location /api {
            rewrite /api/(.*)  /$1 break;
            proxy_pass http://hm:8080;
        }
    }
}

2. 运行Nginx镜像

docker run -d --name nginx -p 18080:18080 -p 18081:18081 -v /root/docker/nginx/html:/usr/share/nginx/html -v /root/docker/nginx/nginx.conf:/etc/nginx/nginx.conf --network hw nginx


http://www.kler.cn/news/337819.html

相关文章:

  • 电子摄像头分割系统源码&数据集分享
  • RKMEDIA画面质量调节-QP调节
  • 电脑怎么卸载软件?学会这6个卸载软件技巧就够了(精选)
  • 基于Tensorrt C++ API 构建YOLOV5实现engine以及推理
  • PhpStudy-PHP5.4.45后门漏洞应用程序(C++/base64/winhttp)
  • OmniCorpus数据集:最大(百亿级别)多模态数据集
  • 深入理解C语言中的内存分配函数:malloc、calloc、realloc
  • Modern CMake 简明教程(5)- 安装
  • Redis篇(面试题 - 连环16炮)(持续更新迭代)
  • 【笔记】I/O总结王道强化视频笔记
  • WSL--安装各种软件包
  • 《Linux从小白到高手》进阶实操篇:Linux找回Root用户密码
  • 掌握这17个Python自动化操作,简化你的日常工作流程,提升工作效率!
  • FDS-112 土壤盐分传感器 三针 自带温度补偿功能
  • 【爬虫】网站反debugger、内存爆破以及网站限制开发者工具
  • 教培机构如何向知识付费转型
  • github命令行管理工具推荐
  • kubernetes基础操作(pod生命周期)
  • mysql系统常用参数查询命令
  • Python去除字符串中的括号