简体   繁体   English

Docker 与 Angular 502 Bad Gateway 组合

[英]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.

相关问题 无法在 AWS 上部署 Scully (Angular) 应用程序:502 Bad Gateway - Can't deploy Scully (Angular) app on AWS: 502 Bad Gateway 502 Bad Gateway on Angular 应用程序部署在 K8 集群上 - 502 Bad Gateway on Angular App deployed on K8 cluster Angular pod healthy but bad gateway (502),如何进一步调试? - Angular pod healthy but bad gateway (502) , how to debug further? Docker 与 Angular、Express.js 和 Nginx 组合 - 502 响应 - Docker Compose with Angular, Express.js and Nginx - 502 response 即使服务器状态显示为在线,也会在我的角度解耦项目上获得502 Bad Gateway - Getting a 502 Bad Gateway on my angular decoupled project even though the server status shows as online 在 k8 中为我的 angular 应用程序获取 502 Bad Gateway nginx/1.13.9 - Getting 502 Bad Gateway nginx/1.13.9 for my angular app in k8's 部署到 Kubernetes 集群后启动 angular 应用程序时出现 502 bad gateway 错误 - 502 bad gateway error while launching the angular application after deploying to Kubernetes cluster 将 angular 应用程序部署到 Kube.netes 集群后出现 Nginx 502 bad gateway 错误 - Nginx 502 bad gateway error after deploying the angular application to Kubernetes cluster Kube.netes Ingress 502 错误网关连接被拒绝 - Kubernetes Ingress 502 Bad Gateway Connection Refused 调用api时Nginx 502 Bad Gateway错误 - Nginx 502 Bad Gateway error when call api
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM