Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mongodb nginx angular 5反向代理mongo图像_Mongodb_Angular_Docker_Reverse Proxy - Fatal编程技术网

Mongodb nginx angular 5反向代理mongo图像

Mongodb nginx angular 5反向代理mongo图像,mongodb,angular,docker,reverse-proxy,Mongodb,Angular,Docker,Reverse Proxy,我能够让反向代理为我的angular 5项目工作。与下面的文件。我对Angular和nginx非常陌生。在我对接客户端和nginx等之前,我只是在一个路径下安装了所有东西。 所以我只运行了一个npm安装,我使用了NPMStart、ng build-prod和ng serve 我只是对Angular 2版本5有点困惑,我以为我是在尝试将客户端与服务器分离。知道Angular 2在客户端运行大多数事情。但是现在看起来我的app.js仍然在同一个“客户端”容器中被调用。 我是否应该将express服务

我能够让反向代理为我的angular 5项目工作。与下面的文件。我对Angular和nginx非常陌生。在我对接客户端和nginx等之前,我只是在一个路径下安装了所有东西。 所以我只运行了一个npm安装,我使用了NPMStart、ng build-prod和ng serve

我只是对Angular 2版本5有点困惑,我以为我是在尝试将客户端与服务器分离。知道Angular 2在客户端运行大多数事情。但是现在看起来我的app.js仍然在同一个“客户端”容器中被调用。 我是否应该将express服务器分离并装箱?这样做的好处是什么

我还将从一个容器中运行mongo映像。将客户端容器链接到mongo是否正确

nginx default.conf

   server {
location / {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass http://client:4200/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
   }
}
docker-compose.yml

   version: '2'

services:
  # Build the container using the client Dockerfile
   client:
   build: ./
  # This line maps the contents of the client folder into the container.
   volumes:
    - ./:/usr/src/app
    links:
     - mongo
    depends_on:
    - mongo
  mongo:      
    image: mongo
    container_name: "mongodb"
    environment:           
    - MONGO_DATA_DIR=/data/db
    - MONGO_LOG_DIR=/dev/null
   volumes:
    - ./data/db:/data/db
   ports:
    - 27017:27017
   command: mongod --smallfiles --logpath=/dev/null # --quiet
  # Build the container using the nginx Dockerfile
 nginx:
  build: ./nginx
   # Map Nginx port 80 to the local machine's port 80
  ports:
    - "80:80"
   # Link the client container so that Nginx will have access to it
  links:
    - client
Dockerfile

  #  Create a new image from the base nodejs 7 image.
 FROM node:8.1.4-alpine as builder
 # Create the target directory in the imahge
 RUN mkdir -p /usr/src/app
 # Set the created directory as the working directory
 WORKDIR /usr/src/app
# Copy the package.json inside the working directory
 COPY package.json /usr/src/app
 # Install required dependencies
 RUN npm install 
 # Copy the client application source files. You can use .dockerignore
 to     exlcude files. Works just as .gitignore does.
 COPY . /usr/src/app
 # Open port 4200. This is the port that our development server uses
 EXPOSE 3000
 # Start the application. This is the same as running ng serve.
 CMD ["npm", "start"]

即使在同一容器中运行客户端和服务器节点,它们仍然是分开的。它们位于同一台服务器上并提供服务,但单独运行。api层在节点上运行,angular应用程序在客户端上运行


你所拥有的是有效的。我有几乎相同的设置。我有两个容器。一个运行express的节点容器,为我的api层和angular应用程序提供服务。然后我将mongo集装箱作为db。

您好,我现在有4个集装箱,它们都在运行,因此我现在有单独的快递,但是,即使我可以ping到集装箱内的集装箱,我感觉港口转运是错误的?当我使用docker端口客户端或docker端口服务器时,什么都不显示。这是正常的行为吗?我现在正试图通过telnet连接到它,我已经为此奋斗了好几天了。继续timeouts@oudekaas这可能是很多事情。你能从你的机器上点击你的服务器吗?是的,很好,我能ping它。在这里查看我的最新问题,了解更多详细信息。netstat没有显示容器的任何ip或端口,我应该能够从容器外部或内部远程登录到相应容器的ip/端口吗?使用通过compose创建的标准网络up@oudekaas您正在运行docker工具箱还是docker社区版