How to host multiple dockerized websites (ngnix) in one ip address?

rahul

Here is my scenario: 1. I have an aws ec2 machine (coreOs) 2. I have hosted multiple APIs in that - all in docker containers 3. I have HA proxy listening to another port that listens to certain port (say 999) and load balances multiple APIs. Works perfectly ... 4. I have another ngnix container which hosts my angular site. This obviously listens to port 80. Assume it's mapped to http://pagladasu.com

What I want is create http://one.pagladasu.com and http://two.pagladasu.com and so forth. And want each pointing to different angular application in the docker containers.

Issue is - both need to listen to port 80 - so how to accomplish tha?

Ben Whaley

Create a container that listens on port 80 and runs Nginx. Configure Nginx with virtual hosts for each of your subdomains (one.pagladasu.com, two.pagladasu.com), using proxy_pass to send the connections to upstream angular containers. Something like this:

server {
    listen 80;
    server_name one.pagladasu.com;

    location / {
        proxy_pass http://one-pagladasu-com;
    }
}
server {
    listen 80;
    server_name two.pagladasu.com;

    location / {
        proxy_pass http://two-pagladasu-com;
    }
}

Link this Nginx container to the two angular containers. Docker will modify /etc/hosts for you so that you may refer to them by name. In this case I've assumed they are named like one-pagladasu-com but of course it can be anything.

Now the flow is Requests => Nginx virtual hosts container => Angular container => HAProxy => APIs.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Is it ok to host multiple sites on a server with one IP address?

From Dev

Multiple websites on nginx, one IP

From Dev

Multiple websites on nginx, one IP

From Dev

One IP address, Two Websites, on Two Machines - Need details

From Dev

One IP address, Two Websites, on Two Machines - Need details

From Dev

How to assign multiple fixed ip address for one domain?

From Dev

How to Redirect marked packets on multiple ports to one IP Address

From Dev

How to change ip address of host at runtime?

From Dev

How are some websites able to get my private IP address?

From Dev

How to access a website by IP address in a server that hosts many websites?

From Dev

How do I host multiple physical Web servers behind a single IP address?

From Dev

Host Multiple Domains on One Server/IP

From Dev

Getting IP address of host

From Dev

When multiple client hosts are behind a NAT sharing one 'external' IP address, how do multiple clients to connect concurrently to the same address?

From Dev

How to host multiple websites on a Standard Azure Websites Instance, Is this a Web Hosting Plan?

From Dev

How can I use DD-WRT to resolve multiple hostnames to one IP address?

From Java

How to get the IP address of the docker host from inside a docker container

From Java

How to get a Docker container's IP address from the host

From Dev

How to get local host IP address in docker container?

From Dev

How to parse IP Address or Host name containing Alpha Characters?

From Dev

How to get the IP address used by a Parallels VM from the host?

From Dev

How do I resolve samba share to IP address or host name

From Dev

How to batch reverse resolve ip address with host command under linux?

From Dev

How does a browser distinguish whether the address in the address bar is an IP address or a Host name?

From Dev

Virtualbox: get host IP address

From Dev

Python: match one of multiple regex patterns and extract IP address if match

From Dev

Docker container with multiple network interfaces: get only one IP address

From Dev

Why is Dockerized Hadoop datanode registering with the wrong IP address?

From Dev

multiple static IP address

Related Related

  1. 1

    Is it ok to host multiple sites on a server with one IP address?

  2. 2

    Multiple websites on nginx, one IP

  3. 3

    Multiple websites on nginx, one IP

  4. 4

    One IP address, Two Websites, on Two Machines - Need details

  5. 5

    One IP address, Two Websites, on Two Machines - Need details

  6. 6

    How to assign multiple fixed ip address for one domain?

  7. 7

    How to Redirect marked packets on multiple ports to one IP Address

  8. 8

    How to change ip address of host at runtime?

  9. 9

    How are some websites able to get my private IP address?

  10. 10

    How to access a website by IP address in a server that hosts many websites?

  11. 11

    How do I host multiple physical Web servers behind a single IP address?

  12. 12

    Host Multiple Domains on One Server/IP

  13. 13

    Getting IP address of host

  14. 14

    When multiple client hosts are behind a NAT sharing one 'external' IP address, how do multiple clients to connect concurrently to the same address?

  15. 15

    How to host multiple websites on a Standard Azure Websites Instance, Is this a Web Hosting Plan?

  16. 16

    How can I use DD-WRT to resolve multiple hostnames to one IP address?

  17. 17

    How to get the IP address of the docker host from inside a docker container

  18. 18

    How to get a Docker container's IP address from the host

  19. 19

    How to get local host IP address in docker container?

  20. 20

    How to parse IP Address or Host name containing Alpha Characters?

  21. 21

    How to get the IP address used by a Parallels VM from the host?

  22. 22

    How do I resolve samba share to IP address or host name

  23. 23

    How to batch reverse resolve ip address with host command under linux?

  24. 24

    How does a browser distinguish whether the address in the address bar is an IP address or a Host name?

  25. 25

    Virtualbox: get host IP address

  26. 26

    Python: match one of multiple regex patterns and extract IP address if match

  27. 27

    Docker container with multiple network interfaces: get only one IP address

  28. 28

    Why is Dockerized Hadoop datanode registering with the wrong IP address?

  29. 29

    multiple static IP address

HotTag

Archive