Skip to content

Instantly share code, notes, and snippets.

@xmalinov
Created October 5, 2020 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xmalinov/0560306ef14bd08432a384fea2282053 to your computer and use it in GitHub Desktop.
Save xmalinov/0560306ef14bd08432a384fea2282053 to your computer and use it in GitHub Desktop.
Docker multiple sites
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
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"]
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