【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
原文地址:https://blog.csdn.net/qq_45722630/article/details/142747644
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!