【发布时间】:2019-05-29 04:10:10
【问题描述】:
我正在设置来自nginx 的 Docker 映像,以将 Vue 应用程序作为静态文件提供服务。
我的 vue 应用程序使用 Vue-Router,它可以在其他服务器上完美运行。
我的 nginx 配置是这样的:
https://router.vuejs.org/guide/essentials/history-mode.html#example-server-configurations
现在我想迁移到 docker,这是我的Dockerfile
# build stage
FROM node:9.11.1-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# production stage
FROM nginx:1.15.8-alpine as production-stage
COPY docker/nginx/prod.conf /etc/nginx/nginx.conf/prod.conf # [*]
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
这是docker/nginx/prod.conf
server {
listen 80;
server_name _ default_server;
root /usr/share/nginx/html;
location / {
try_files $uri $uri/ /index.html;
}
}
它适用于主页,例如:http://192.168.1.10 但在其他 URL 上得到 404,例如 http://192.168.1.10/settings
prod.conf 已复制到 nginx 文件夹中,我确实看到了。
你有什么想法,还是我错过了什么?
【问题讨论】:
标签: docker nginx vue-router