[英]Docker compose with angular 502 Bad Gateway
I am using docker compose to put my application on a server.我正在使用 docker compose 将我的应用程序放在服务器上。 I have three containers whith, angular, spring and https-portal.
我有三个容器 whith、angular、spring 和 https-portal。 My docker compose file:
我的码头工人撰写文件:
version: '3.3'
services:
web:
build: './blooming_frontend'
ports:
- 4200:80
depends_on:
- spring
spring:
build: ./blooming_backend
ports:
- 8080:8080
https-portal:
image: steveltn/https-portal:1
depends_on:
- web
- spring
ports:
- 80:80
- 443:443
restart: always
volumes:
- ./ssl_certs:/var/lib/https-portal
environment:
DOMAINS: 'www.bloomingthebrand.com -> http://web:4200 #production'
And the docker file for Angular service以及 Angular 服务的 docker 文件
FROM node:14.13
MAINTAINER Blooming The Brand dev team <info@bloomingthebrand.com>
# set working directory
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
# add .bin to $PATH
ENV PATH /usr/src/app/node_modules/.bin:$PATH
# install package.json (o sea las dependencies)
COPY package.json /usr/src/app/package.json
RUN npm install
RUN npm install -g @angular/cli@10.0.3
# add app
COPY . /usr/src/app
# start app
CMD npm start
When I try to access to www.bloomingthebrand.com the server return 502 Gateway Error ngix当我尝试访问www.bloomingthebrand.com 时,服务器返回 502 网关错误 ngix
Angular application is up in port 4200 Angular 应用程序在端口 4200 中启动
when you want to access a container from another one, you need to do so on the container's port, not the exposed one.当你想从另一个容器访问一个容器时,你需要在容器的端口上这样做,而不是在暴露的端口上。 In fact, in your case you don't need to expose 4200, unless you want to bypass the
https-portal
实际上,在您的情况下,您不需要公开 4200,除非您想绕过
https-portal
That is, change 4200 for 80 here DOMAINS: 'www.bloomingthebrand.com -> http://web:4200 #production'
, or just don't set the port as it's the default HTTP.也就是说,在
DOMAINS: 'www.bloomingthebrand.com -> http://web:4200 #production'
将 4200 更改为 80,或者只是不要设置端口,因为它是默认的 HTTP。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.