【发布时间】:2019-01-22 08:48:06
【问题描述】:
我遇到了另一个单独的问题,但我在 following post 中找到了解决方案。正如那里所建议的,我需要通过添加部分来修改我的nginx server
http {
## ...
## other configuration
server {
listen 80;
server_name yourservername.com;
root html/path_to_your_project;
index index.php index.html;
location / {
try_files $uri $uri/ /index.html;
}
}
}
在文件中:etc/nginx/sites-enabled/default.cnf,似乎已经有标签server {,我只需要在其中添加上面的部分。
但是,由于我使用的是 docker 映像而不是真正的服务器本身,因此我不确定如何完成此操作。这是我的.Dockerfile,我不确定我需要在其中进行哪些更改。
# build stage
FROM node:9.11.1-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm i npm@latest -g && \
npm install
COPY . .
RUN node build/build.js
# production stage
FROM nginx:1.13.12-alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
【问题讨论】:
-
我将基于 alpine 创建自己的映像,并安装和配置 nginx,然后将其用作文件的映像。所以基本上我会拉一个高山图像启动一个交互式会话编辑 nginx .cnf 文件保存它就可以了。
标签: docker nginx dockerfile nginx-config docker-command