Compose files, instructions and extras for using my automatic proxy containers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

docker-compose.yml 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. ---
  2. # Sets up a series of containers to automatically provision SSL certificates
  3. # and configure nginx for reverse proxying. Containers that should be proxied
  4. # need to be labelled with the following:
  5. #
  6. # com.chameth.vhost="main.domain.com,alternate.domain.com,alt2.com,..."
  7. # com.chameth.proxy=80
  8. # com.chameth.proxy.protocol=http [optional, defaults to http]
  9. #
  10. # To prove ownership of domains to Let's Encrypt, we add a DNS entry when
  11. # required. This requires you to provide authentication details (e-mail
  12. # address, API key, password, etc). These should be specified in a
  13. # docker-compose.override.yml file.
  14. version: '2'
  15. services:
  16. # etcd is a key-value server. We use it to store meta-data about docker
  17. # containers which is then read by the service containers below.
  18. #
  19. # etcd can be distributed and accessed remotely, but this config is for
  20. # a single node instance.
  21. etcd:
  22. image: quay.io/coreos/etcd:v2.3.3
  23. container_name: autoproxy_etcd
  24. restart: always
  25. command: >-
  26. --name etcd0
  27. --initial-cluster etcd0=http://127.0.0.1:2380
  28. --initial-advertise-peer-urls http://127.0.0.1:2380
  29. --initial-cluster-state new
  30. --initial-cluster-token etcd-cluster-1
  31. --bind-addr 0.0.0.0:2379
  32. networks:
  33. - etcd-services
  34. # service-reporter interacts with docker (which is why it needs the
  35. # docker.sock mounted) to get a list of current containers, and
  36. # monitor when containers are added or removed. It keeps the information
  37. # in etcd up-to-date.
  38. reporter:
  39. image: csmith/service-reporter:latest
  40. container_name: autoproxy_reporter
  41. restart: always
  42. links:
  43. - etcd:etcd
  44. volumes:
  45. - /var/run/docker.sock:/var/run/docker.sock
  46. networks:
  47. - etcd-services
  48. depends_on:
  49. - etcd
  50. # service-letsencrypt reads a list of vhosts from container labels
  51. # (via etcd), and prepares a domains.txt file to send on to one of
  52. # the letsencrypt-* containers below.
  53. letsencrypt-updater:
  54. image: csmith/service-letsencrypt:latest
  55. container_name: autoproxy_letsencrypt-updater
  56. restart: always
  57. volumes:
  58. - letsencrypt-data:/letsencrypt
  59. networks:
  60. - etcd-services
  61. depends_on:
  62. - etcd
  63. # letsencrypt-lexicon obtains Let's Encrypt certificates by modifying
  64. # DNS records. It supports several major cloud DNS providers.
  65. letsencrypt-lexicon:
  66. image: csmith/letsencrypt-lexicon:latest
  67. container_name: autoproxy_letsencrypt-lexicon
  68. restart: always
  69. volumes:
  70. - letsencrypt-data:/letsencrypt
  71. # letsencrypt-generic uses a user-defined hook to update DNS entries.
  72. # You need to supply your own hook, available at /dns/hook. See the
  73. # letsencrypt.sh repo for details about hook arguments.
  74. #letsencrypt-generic:
  75. # image: csmith/letsencrypt-generic:latest
  76. # container_name: autoproxy_letsencrypt-generic
  77. # restart: always
  78. # volumes:
  79. # - letsencrypt-data:/letsencrypt
  80. # - /my/hook/script:/dns/hook
  81. # service-nginx reads proxy information and vhosts from etcd and
  82. # creates an nginx vhost config to enable SSL-terminated reverse
  83. # proxying to the containers.
  84. nginx-updater:
  85. image: csmith/service-nginx:latest
  86. container_name: autoproxy_nginx-updater
  87. restart: always
  88. volumes:
  89. - nginx-config:/nginx-config
  90. - letsencrypt-data:/letsencrypt
  91. networks:
  92. - etcd-services
  93. depends_on:
  94. - etcd
  95. # Finally, nginx is what actually does the SSL termination and
  96. # reverse proxying. Because it needs to connect to containers
  97. # on (potentially) many different networks, we set the
  98. # network_mode to host.
  99. nginx:
  100. image: nginx:1.13
  101. container_name: autoproxy_nginx
  102. restart: always
  103. volumes:
  104. - nginx-config:/etc/nginx/conf.d
  105. - letsencrypt-data:/letsencrypt
  106. ports:
  107. - 80:80
  108. - 443:443
  109. network_mode: host
  110. # We use this container to monitor for nginx config file and SSL cert changes
  111. # (using inotify) and send nginx a SIGHUP signal.
  112. nginx-config-hupper:
  113. image: pstauffer/inotify:latest
  114. container_name: autoproxy_nginx-config-hupper
  115. restart: always
  116. volumes:
  117. - nginx-config:/monitor/nginx
  118. - letsencrypt-data:/monitor/letsencrypt
  119. - /var/run/docker.sock:/var/run/docker.sock
  120. environment:
  121. - 'CONTAINER=autoproxy_nginx'
  122. - 'VOLUMES=/monitor'
  123. - 'INOTIFY_OPTONS=--monitor --exclude=*.sw[px] --recursive'
  124. volumes:
  125. letsencrypt-data:
  126. nginx-config:
  127. networks:
  128. etcd-services: