准备文件

  • 新建nginx目录、nginx/logs目录、nginx/web目录、conf.d目录
  • 在nginx/conf.d目录下新建文件default.conf
    server {
       listen    80;
       server_name  localhost;
       client_max_body_size 10m;
       proxy_max_temp_file_size   30m;
       proxy_connect_timeout 300;
       proxy_read_timeout 300;
       proxy_send_timeout 300;
    
    
       location /  {
             root  /web;
             index index.html;
             try_files $uri /index.html;
       }
    
      location /api/ {
             proxy_pass   http:xxxxxx;
      }
    }
    

docker-compose.yml

version: '3'
services:
  nginx:
    image: nginx
    container_name: nginx
    restart: always
    ports:
      - 80:80
    volumes:
    - ./web:/web
    - ./logs:/var/log/nginx
    - ./conf.d:/etc/nginx/conf.d
  • 启动容器
docker-compose up -d
Logo

码道开发者社区,聚焦华为云码道 CodeArts 代码智能体,沉淀 Agent、Skill、鸿蒙开发实战内容,供开发者查阅资料、交流技术、分享工程实践

更多推荐