如何解决nginx需要其他配置docker
我最近一直在与docker纠缠,目前正在部署带有Express / Node后端的React应用程序。我将NGINX用于反向代理,并将docker用于部署。我的站点设置正确,减去了react-router的实现。修好后,我开始收到消息;
欢迎使用nginx!
如果看到此页面,则说明已成功安装Nginx Web服务器 和工作。需要进一步的配置。
有关在线文档和支持,请访问nginx.org。 可在nginx.com上获得商业支持。
感谢您使用nginx。
我将在下面共享一些代码,因为我不知道我可能需要什么其他配置...非常感谢您的帮助!
Dockerfile
# build frontend
FROM node:alpine as build
WORKDIR /app
COPY package*.json /app/
RUN npm install
COPY . /app/
RUN npm run build
# nginx and prod
FROM nginx:alpine
COPY --from=build /app/build /usr/share/nginx.html
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx/nginx.conf /etc/nginx/conf.d
EXPOSE 8080
nginx配置
server {
listen 8080;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html; }
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
docker-compose在项目的根目录
version: '2'
services:
boobz-client:
build: ./boobz-client
ports:
- '8080:8080'
depends_on:
- boobz-api
boobz-api:
build: ./boobz-api
ports:
- '5000:5000'
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。