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.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. You will need to configure one of the letsencrypt-* services
  12. # below to make these changes.
  13. version: '2'
  14. services:
  15. # etcd is a key-value server. We use it to store meta-data about docker
  16. # containers which is then read by the service containers below.
  17. #
  18. # etcd can be distributed and accessed remotely, but this config is for
  19. # a single node instance.
  20. etcd:
  21. image: quay.io/coreos/etcd:v2.3.3
  22. container_name: autoproxy_etcd
  23. restart: always
  24. command: >-
  25. --name etcd0
  26. --initial-cluster etcd0=http://127.0.0.1:2380
  27. --initial-advertise-peer-urls http://127.0.0.1:2380
  28. --initial-cluster-state new
  29. --initial-cluster-token etcd-cluster-1
  30. --bind-addr 0.0.0.0:2379
  31. networks:
  32. - etcd-services
  33. # service-reporter interacts with docker (which is why it needs the
  34. # docker.sock mounted) to get a list of current containers, and
  35. # monitor when containers are added or removed. It keeps the information
  36. # in etcd up-to-date.
  37. reporter:
  38. image: csmith/service-reporter:latest
  39. container_name: autoproxy_reporter
  40. restart: always
  41. links:
  42. - etcd:etcd
  43. volumes:
  44. - /var/run/docker.sock:/var/run/docker.sock
  45. networks:
  46. - etcd-services
  47. depends_on:
  48. - etcd
  49. # service-letsencrypt reads a list of vhosts from container labels
  50. # (via etcd), and prepares a domains.txt file to send on to one of
  51. # the letsencrypt-* containers below.
  52. letsencrypt-updater:
  53. image: csmith/service-letsencrypt:latest
  54. container_name: autoproxy_letsencrypt-updater
  55. restart: always
  56. volumes:
  57. - letsencrypt-data:/letsencrypt
  58. networks:
  59. - etcd-services
  60. depends_on:
  61. - etcd
  62. # letsencrypt-lexicon obtains Let's Encrypt certificates by modifying
  63. # DNS records. It supports several major cloud DNS providers. You
  64. # need to set the provider and auth tokens below.
  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. environment:
  72. - STAGING=yes
  73. - EMAIL=your@email.addr
  74. - PROVIDER=cloudflare
  75. - LEXICON_CLOUDFLARE_USERNAME=your@email.addr
  76. - LEXICON_CLOUDFLARE_TOKEN=1234567890123456789012345678901234567890
  77. # letsencrypt-generic uses a user-defined hook to update DNS entries.
  78. # You need to supply your own hook, available at /dns/hook. See the
  79. # letsencrypt.sh repo for details about hook arguments.
  80. #letsencrypt-generic:
  81. # image: csmith/letsencrypt-generic:latest
  82. # container_name: autoproxy_letsencrypt-generic
  83. # restart: always
  84. # volumes:
  85. # - letsencrypt-data:/letsencrypt
  86. # - /my/hook/script:/dns/hook
  87. # environment:
  88. # - STAGING=yes
  89. # - EMAIL=your@email.addr
  90. # service-nginx reads proxy information and vhosts from etcd and
  91. # creates an nginx vhost config to enable SSL-terminated reverse
  92. # proxying to the containers.
  93. nginx-updater:
  94. image: csmith/service-nginx:latest
  95. container_name: autoproxy_nginx-updater
  96. restart: always
  97. volumes:
  98. - nginx-config:/nginx-config
  99. networks:
  100. - etcd-services
  101. depends_on:
  102. - etcd
  103. # Finally, nginx is what actually does the SSL termination and
  104. # reverse proxying. Because it needs to connect to containers
  105. # on (potentially) many different networks, we set the
  106. # network_mode to host.
  107. nginx:
  108. image: nginx:1.11
  109. container_name: autoproxy_nginx
  110. restart: always
  111. volumes:
  112. - nginx-config:/etc/nginx/conf.d
  113. - letsencrypt-data:/letsencrypt
  114. ports:
  115. - 80:80
  116. - 443:443
  117. network_mode: host
  118. # We use inotify-signal-container to monitor for nginx config
  119. # file and SSL cert changes (using inotify) and send nginx a
  120. # SIGHUP signal.
  121. nginx-config-hupper:
  122. image: masm/inotify-signal-container:latest
  123. container_name: autoproxy_nginx-config-hupper
  124. restart: always
  125. volumes:
  126. - nginx-config:/monitor/nginx
  127. - letsencrypt-data:/monitor/letsencrypt
  128. - /var/run/docker.sock:/var/run/docker.sock
  129. command:
  130. - autoproxy_nginx
  131. - SIGHUP
  132. - /monitor
  133. volumes:
  134. letsencrypt-data:
  135. nginx-config:
  136. networks:
  137. etcd-services: