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?
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.
Comments