Docker nginx Multi-domain configuration problem

Source: Internet
Author: User
Tags docker run
Attempt to configure the Dockers official Nginx image nginx.conf configuration failed, it is very little known about the basic Search tutorial.
Here's the process I tried:
Yba

docker run -d   --name YBa --restart=always  -v /Storage/Volumes/App/YBa:/usr/src/myapp php

YBb

docker run -d   --name YBa --restart=always  -v /Storage/Volumes/App/YBb:/usr/src/myapp php

Nginx

docker run -d -p 80:80 --name Nginx  --link YBa:yba  --link YBb:ybb  -v /Storage/Volumes/Services/Nginx/Conf/nginx.conf/nginx.conf:/etc/nginx/nginx.conf:ro --restart=always nginx

Nginx.conf

    user nobody nogroup;events {   worker_connections 512; }http {   upstream yba {    server yba;   }  upstream ybb {    server ybb;   }  server {    listen *:80;     server_name http://app1.com;     location / {       proxy_pass http://yba/;       proxy_set_header   X-Real_IP $remote_addr;      proxy_set_header   Host      $http_host;    }      }}  server {    listen *:80;     server_name http://app2.com;     location / {       proxy_pass http://ybb/;       proxy_set_header   X-Real_IP $remote_addr;      proxy_set_header   Host      $http_host;    }      }}          

The question now is how to complete multiple domains with multiple containers through a single configuration file
Want to know if there's any other way around
How to point to multiple primary domain names for different subdirectories of a single container

Reply content:

Attempt to configure the Dockers official Nginx image nginx.conf configuration failed, it is very little known about the basic Search tutorial.
Here's the process I tried:
Yba

docker run -d   --name YBa --restart=always  -v /Storage/Volumes/App/YBa:/usr/src/myapp php

YBb

docker run -d   --name YBa --restart=always  -v /Storage/Volumes/App/YBb:/usr/src/myapp php

Nginx

docker run -d -p 80:80 --name Nginx  --link YBa:yba  --link YBb:ybb  -v /Storage/Volumes/Services/Nginx/Conf/nginx.conf/nginx.conf:/etc/nginx/nginx.conf:ro --restart=always nginx

Nginx.conf

    user nobody nogroup;events {   worker_connections 512; }http {   upstream yba {    server yba;   }  upstream ybb {    server ybb;   }  server {    listen *:80;     server_name http://app1.com;     location / {       proxy_pass http://yba/;       proxy_set_header   X-Real_IP $remote_addr;      proxy_set_header   Host      $http_host;    }      }}  server {    listen *:80;     server_name http://app2.com;     location / {       proxy_pass http://ybb/;       proxy_set_header   X-Real_IP $remote_addr;      proxy_set_header   Host      $http_host;    }      }}          

The question now is how to complete multiple domains with multiple containers through a single configuration file
Want to know if there's any other way around
How to point to multiple primary domain names for different subdirectories of a single container

The corresponding configuration file can be configured locally on conf/, example conf/api.app2.com.conf, when the container is created, add the Dockerfile code as follows

From nginx:1.9MAINTAINER terry.dawu@gmail.comADD nginx.conf /etc/nginx/nginx.confADD conf/* /etc/nginx/conf.d/RUN mkdir /opt/www && mkdir /opt/logRUN chmod -R 755 /opt/log /opt/wwwVOLUME ["/opt"]

    1. Nginx proxy distribution, pointing to different ports on this machine

    2. CDN distribution, pointing to different ports on the server

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.