react - docker host not found in upstream

流过昼夜 提交于 2021-01-29 08:49:18

问题


I released my reactJs application. I have code information as below. But I get the error "11 # 11: host not found in upstream". where could i have made a mistake Could you help ?

I get an upStream error even though my docker, nginx, and docker-compose file is correct. I had run the same codes before but I could not find where I made changes.

default.conf

`

 upstream frontend_server{
      server web:3000;
 }

  server{
   listen 80;
   resolver 127.0.0.11;

   location /.well-known/acme-challenge/ {
       root /var/www/certbot;
   }
   location / {
       return 301 https://$host$request_uri;
   }
  } 
  # SSL
 server {
   listen 443 ssl;
   resolver 127.0.0.11;

   ssl_certificate /usr/share/nginx/certificates/fullchain.pem;
   ssl_certificate_key /usr/share/nginx/certificates/privkey.pem;
   include /etc/ssl-options/options-nginx-ssl.conf;
   ssl_dhparam /etc/ssl-options/ssl-dhparams.pem;

 location / {
   proxy_pass http://frontend_server;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
   proxy_set_header Host $host;
   proxy_redirect off;

   #Websocket support
   proxy_http_version 1.1;
   proxy_set_header Upgrade $http_upgrade;
   proxy_set_header Connection "upgrade";
 }
}

`

docker-compose.yml

`

 version: '3'
 services:
   nginxproxy:
     build:
       context: .
       dockerfile: Dockerfile.lets
     container_name: nginxproxy
     networks:
      - nginx_network
     restart: always
     expose:
       - 80
     ports:
       - "443:443"
       - "80:80"
     environment:
       DOMAIN: mySiteaddress.com
       EMAIL: myMail@hotmail.com
       RENEW_INTERVAL: 12h
     volumes:
       - ./certificates:/usr/share/nginx/certificates
       - ./default.conf:/etc/nginx/conf.d/default.conf

   web:
     build:
       context: .
       dockerfile: Dockerfile.dev
     container_name: web
     networks:
      - nginx_network
     expose:
       - 3000
     ports:
        - "3000:3000"
     depends_on:
       - nginxproxy
     volumes:
       - /app/node_modules
       - .:/app
   tests:
     build:
       context: .
       dockerfile: Dockerfile.dev
     container_name: tests
     volumes:
       - /app/node_modules
       - .:/app
     command: ["npm","run","test"]


 networks:
   nginx_network:
     driver: bridge

`

Dockerfile.dev

`

 FROM node:alpine
 WORKDIR '/app'
 COPY package.json .
 RUN npm install
 COPY . . 
 EXPOSE 3000
 CMD ["npm", "run", "start"]

`

Dockerfile.lets

`

 FROM nginx:1.15-alpine
 RUN apk add inotify-tools certbot openssl ca-certificates
 WORKDIR /opt
 COPY entrypoint.sh nginx-letsencrypt
 COPY certbot.sh certbot.sh
 COPY ssl-options/ /etc/ssl-options
 COPY default.conf /etc/nginx/conf.d/default.conf
 RUN chmod +x nginx-letsencrypt && \
     chmod +x certbot.sh

 EXPOSE 443

 ENTRYPOINT ["./nginx-letsencrypt"]
 CMD ["nginx", "-g", "daemon off;"]

`

package.json

`

 {
    "name": "customer_Flow",
    "version": "1.0.0",
    "description": "Customer flow",
    "copyright": "Copyright 2019",
    "license": "MIT",
    "private": true,
    "repository": {
    "type": "git",
         "url": "git@github.com:coreui/coreui-free-react-admin-template.git"
   },
   "dependencies": {
     "@coreui/coreui": "^2.1.16",
     "@coreui/coreui-plugin-chartjs-custom-tooltips": "^1.3.1",
     "@coreui/icons": "0.3.0",
     "@coreui/react": "^2.5.7",
     "@date-io/date-fns": "^2.6.1",
     "@devexpress/dx-react-chart": "^2.6.2",
     "@devexpress/dx-react-chart-material-ui": "^2.6.2",
     "@devexpress/dx-react-core": "^2.6.2",
     "@devexpress/dx-react-grid": "^2.6.0",
     "@devexpress/dx-react-grid-material-ui": "^2.6.0",
     "@devexpress/dx-react-scheduler": "^2.6.0",
     "@devexpress/dx-react-scheduler-material-ui": "^2.6.0",
     "@material-ui/core": "^4.9.8",
     "@material-ui/icons": "^4.9.1",
     "bootstrap": "^4.4.1",
     "chart.js": "^2.9.2",
     "classnames": "^2.2.6",
     "core-js": "^3.6.4",
     "cors": "^2.8.5",
     "corsproxy": "^1.5.0",
     "date-fns": "^2.12.0",
     "dotenv": "^8.2.0",
     "enzyme": "^3.11.0",
     "enzyme-adapter-react-16": "^1.15.2",
     "flag-icon-css": "^3.4.6",
     "font-awesome": "^4.7.0",
     "http-proxy-middleware": "^0.20.0",
     "jquery": "^3.4.1",
     "jwt-decode": "^2.2.0",
     "moment": "^2.24.0",
     "node-sass": "^4.13.1",
     "nodemon": "^2.0.2",
     "prettier": "^1.18.2",
     "prop-types": "^15.7.2",
     "react": "^16.13.1",
     "react-alert": "^6.0.1",
     "react-alert-template-basic": "^1.0.0",
     "react-app-polyfill": "^1.0.6",
     "react-chartjs-2": "^2.9.0",
     "react-dom": "^16.13.1",
     "react-notifications-component": "^2.4.0",
      "react-redux": "^7.2.0",
     "react-router-config": "^5.1.1",
     "react-router-dom": "^5.1.2",
     "react-test-renderer": "^16.13.1",
     "reactstrap": "^8.4.1",
     "redux": "^4.0.5",
     "redux-devtools-extension": "^2.13.8",
     "redux-persist": "^6.0.0",
     "redux-thunk": "^2.3.0",
     "simple-line-icons": "^2.4.1",
     "typescript": "^3.8.3"
   },
   "devDependencies": {
     "react-scripts": "^3.4.1"
   },
   "scripts": {
     "start": "react-scripts start",
     "build": "react-scripts build",
     "test": "react-scripts test",
     "test:cov": "npm test -- --coverage --watchAll=false",
     "test:debug": "react-scripts --inspect-brk test --runInBand",
     "eject": "react-scripts eject"
   },
   "bugs": {
     "url": "https://github.com/coreui/coreui-free-react-admin-template/issues"
   },
   "eslintConfig": {
     "extends": "react-app"
   },
   "browserslist": [
     ">0.2%",
     "not dead",
     "not ie <= 9",
     "not op_mini all"
    ],
   "jest": {
     "collectCoverageFrom": [
       "src/**/*.{js,jsx}",
       "!**/*index.js",
       "!src/serviceWorker.js",
       "!src/polyfill.js"
     ]
   },
  "engines": {
     "node": ">=8.10",
     "npm": ">=6"
   }
 }

`

来源:https://stackoverflow.com/questions/61595717/react-docker-host-not-found-in-upstream

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!