我遇到另一个单独的问题,但是我在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 image,而不是真正的服务器本身,因此我不确定如何完成此操作。这是我的.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;"]
答案 0 :(得分:0)
有两种方法可以做到这一点。
这是我使用的docker-compose示例
version: '2.1'
services:
<containerAlias>:
image: <myNginxImage>:<tag>
ports:
- "8080:80"
volumes:
- ./html:/usr/share/nginx/html
- ./config/nginx/nginx.conf:/etc/nginx/nginx.conf
- ./logs/nginx_logs:/var/log/nginx
privileged: true
networks:
<MyNetworkName>:
ipv4_address: <IP>
restart: always
container_name: <containerName>
....
....
....
请确保根据您的环境更改配置。 我希望您选择选项2 。