Created
October 5, 2020 10:01
-
-
Save xmalinov/0560306ef14bd08432a384fea2282053 to your computer and use it in GitHub Desktop.
Docker multiple sites
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "2" | |
services: | |
web1: | |
image: your_image | |
container_name: web1 | |
ports: | |
- 81:80 | |
web2: | |
image: your_image | |
container_name: web2 | |
ports: | |
- 82:80 | |
nginx: | |
build: . | |
container_name: nginx | |
ports: | |
- 80:80 | |
- 443:443 | |
links: | |
- web1 | |
- web2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:20.04 | |
MAINTAINER Test (test@example.com) | |
# install nginx | |
RUN apt-get update -y | |
RUN apt-get install -y python-software-properties | |
RUN apt-get install -y software-properties-common | |
RUN add-apt-repository -y ppa:nginx/stable | |
RUN apt-get update -y | |
RUN apt-get install -y nginx | |
# deamon mode off | |
RUN echo "\ndaemon off;" >> /etc/nginx/nginx.conf | |
RUN chown -R www-data:www-data /var/lib/nginx | |
# volume | |
VOLUME ["/etc/nginx/sites-enabled", "/etc/nginx/certs", "/var/log/nginx"] | |
# expose ports | |
EXPOSE 80 443 | |
# add nginx conf | |
ADD nginx.conf /etc/nginx/conf.d/default.conf | |
WORKDIR /etc/nginx | |
CMD ["nginx"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name test1.com www.test1.com; | |
location / { | |
proxy_pass http://web1:81/; | |
} | |
} | |
server { | |
listen 80; | |
server_name test2.com www.test2.com; | |
location / { | |
proxy_pass http://web1:82/; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment