RuoYi 前端Docker部署
Dockerfile
# 基础镜像 不指定版本则默认最新 FROM nginx # 挂载目录 VOLUME /home/nginx/www/ruoyi # 创建目录 RUN mkdir -p /home/nginx/www/ruoyi # 指定路径 该路径我是自己提前创建好的 WORKDIR /home/nginx/www/ruoyi # 复制conf文件到路径 ./conf/nginx.conf和上面的mysql一个道理 nginx.conf下面会贴出来 COPY /conf/nginx.conf /etc/nginx/nginx.conf # 复制html文件到路径 dist中存放前端项目的打包文件 COPY /dist /home/nginx/www/ruoyi
创建conf文件夹,新建nginx.conf配置
worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { root /home/nginx/www/ruoyi; try_files $uri $uri/ /index.html; index index.html index.htm; } location /prod-api/{ proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #自己服务器地址:没改的话就是默认8080 proxy_pass http://192.168.1.123:9090/; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }