简体   繁体   English

Docker 撰写错误:nginx:在 /etc/nginx/conf.d/default.conf:21 的上游“应用程序”中找不到 [emerg] 主机

[英]Docker compose error: nginx: [emerg] host not found in upstream “app” in /etc/nginx/conf.d/default.conf:21

Trying to run nginx and web application via docker compose尝试通过 docker 组合运行 nginx 和 web 应用程序

dockerfile dockerfile

FROM node:12.16.2 as build

RUN mkdir /app

COPY package*.json ./
RUN npm install

COPY . /app
RUN npm run-script build

COPY --from=build /app/build /var/www/roundmap.app

EXPOSE 3000

nginx config defauls.conf nginx 配置 defauls.conf

server {
  listen 80;
  listen 443 ssl;
  listen 3000;
  server_name *.roundmap.app 185.146.157.206;

  root /var/www/roundmap.app;
  index index.html;

  ssl_certificate /etc/ssl/roundmap/roundmap.crt;
  ssl_certificate_key /etc/ssl/roundmap/roundmap.key;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers HIGH:!aNULL:!MD5;

  if ($scheme = http) {
    return 301 https://$server_name$request_uri;
  }

  location / {
    proxy_pass https://app:3000;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
  }
}

docker-compose.yml docker-compose.yml

version: "4"
services:
    app:
        build: roundmap/
        container_name: app
        ports:
            - 3000:3000
    nginx:
        image: nginx:1.17.2-alpine
        container_name: nginx
        ports:
            - 80:80
            - 443:443
        links:
            - app
        volumes:
            - ./default.conf:/etc/nginx/conf.d/default.conf
            - /etc/ssl/roundmap/roundmap.crt:/etc/ssl/roundmap/roundmap.crt
            - /etc/ssl/roundmap/roundmap.key:/etc/ssl/roundmap/roundmap.key

running via docker-compose up and getting error通过 docker-compose 运行并出现错误

nginx | nginx | 2020/07/20 16:39:19 [emerg] 1#1: host not found in upstream "app" in /etc/nginx/conf.d/default.conf:22 nginx | 2020/07/20 16:39:19 [emerg] 1#1: 在 /etc/nginx/conf.d/default.conf:22 nginx 的上游“应用程序”中找不到主机nginx: [emerg] host not found in upstream "app" in /etc/nginx/conf.d/default.conf:22 nginx exited with code 1 nginx:在 /etc/nginx/conf.d/default.conf:22 的上游“应用程序”中找不到 [emerg] 主机 nginx 以代码 1 退出

Сan you please help where am I mistaken? Сan请你帮助我在哪里弄错了?

In your default.conf replace https://app:3000 by http://app:3000 as SSL termination is happening at Nginx itself, app is still using http. In your default.conf replace https://app:3000 by http://app:3000 as SSL termination is happening at Nginx itself, app is still using http.

Update your docker-compose.yaml更新您的docker-compose.yaml

Use depends_on instead of links , it has deprecated.使用depends_on而不是links ,它已被弃用。

version: "3.8"
services:
    app:
        build: roundmap/
        container_name: app
        command: [ "node", "app.js"]
        ports:
            - 3000:3000
    nginx:
        image: nginx:1.17.2-alpine
        container_name: nginx
        ports:
            - 80:80
            - 443:443
        depends_on:
            - app
        volumes:
            - ./default.conf:/etc/nginx/conf.d/default.conf
            - /etc/ssl/roundmap/roundmap.crt:/etc/ssl/roundmap/roundmap.crt
            - /etc/ssl/roundmap/roundmap.key:/etc/ssl/roundmap/roundmap.key

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 nginx:[emerg] 在 /etc/nginx/conf.d/default.conf 的上游“api:5000”中找不到主机 - nginx: [emerg] host not found in upstream "api:5000" in /etc/nginx/conf.d/default.conf AWS ECR,基于 ECS 的部署:nginx:[emerg] 主机未在上游“app:9000”中找到,位于 /etc/nginx/conf.d/default.conf:2 - AWS ECR, ECS based deployment: nginx: [emerg] host not found in upstream "app:9000" in /etc/nginx/conf.d/default.conf:2 nginx:在 /etc/nginx/conf.d/nginx.conf:12 的上游“php”中找不到 [emerg] 主机 - nginx: [emerg] host not found in upstream "php" in /etc/nginx/conf.d/nginx.conf:12 ERPNEXT - docker frappe/erpnext-nginx:v14 - 在 /etc/nginx/conf.d/default.conf:2 的上游“${BACKEND}”中找不到主机 - ERPNEXT - docker frappe/erpnext-nginx:v14 - host not found in upstream "${BACKEND}" in /etc/nginx/conf.d/default.conf:2 nginx: [emerg] "http" 指令在 /etc/nginx/conf.d/default.conf:1 中是不允许的 - nginx: [emerg] "http" directive is not allowed here in /etc/nginx/conf.d/default.conf:1 使用 docker 和 nginx 部署的 React 应用程序:/etc/nginx/conf.d/default.conf 与包不同 - React app deployed with docker and nginx : /etc/nginx/conf.d/default.conf differs from the packages docker vs docker-compose nginx:[emerg] host在/etc/nginx/nginx.conf:21的上游“httpstat.us”中找不到 - docker vs docker-compose nginx: [emerg] host not found in upstream “httpstat.us” in /etc/nginx/nginx.conf:21 运行独立 docker 容器时,在 /etc/nginx/conf.d/nginx.conf 上游中找不到主机 - host not found in upstream in /etc/nginx/conf.d/nginx.conf when running standalone docker containers /etc/nginx/conf.d/default.conf:1 中的上游“9000”中没有端口 - no port in upstream “9000” in /etc/nginx/conf.d/default.conf:1 无法启动 nginx-proxy docker 映像并显示错误“/etc/nginx/conf.d/default.conf 的内容未更改” - Couldn't start nginx-proxy docker image with error “Contents of /etc/nginx/conf.d/default.conf did not change”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM