【发布时间】:2019-06-09 06:38:50
【问题描述】:
我有一个使用 React 路由器的应用程序,并为它创建了一个 docker 映像。我正在使用 nginx 服务器,它可以工作。但是,刷新页面会给我 nginx 404 错误。我知道我需要覆盖 nginx 配置文件才能使其工作,但不知道为什么它不起作用。
我尝试向nginx.conf 添加某种重定向,只是为了查看它是否会覆盖default.conf,但它不起作用。这些是我的文件:
Dockerfile:
FROM nginx:alpine
COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
nginx.conf
server {
listen 80 default;
server_name localhost;
return 301 https://www.google.com;
}
编辑:
以及如何检查正在运行的配置文件?
【问题讨论】:
-
你使用什么 url 来访问容器?
-
localhost - 我正在用 docker run -p 80:80 前端破坏容器
标签: docker nginx dockerfile nginx-config