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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. command: >-
  24. --name etcd0
  25. --initial-cluster etcd0=http://127.0.0.1:2380
  26. --initial-advertise-peer-urls http://127.0.0.1:2380
  27. --initial-cluster-state new
  28. --initial-cluster-token etcd-cluster-1
  29. --bind-addr 0.0.0.0:2379
  30. networks:
  31. - etcd-services
  32. # service-reporter interacts with docker (which is why it needs the
  33. # docker.sock mounted) to get a list of current containers, and
  34. # monitor when containers are added or removed. It keeps the information
  35. # in etcd up-to-date.
  36. reporter:
  37. image: csmith/service-reporter:latest
  38. container_name: autoproxy_reporter
  39. links:
  40. - etcd:etcd
  41. volumes:
  42. - /var/run/docker.sock:/var/run/docker.sock
  43. networks:
  44. - etcd-services
  45. depends_on:
  46. - etcd
  47. # service-letsencrypt reads a list of vhosts from container labels
  48. # (via etcd), and prepares a domains.txt file to send on to one of
  49. # the letsencrypt-* containers below.
  50. letsencrypt-updater:
  51. image: csmith/service-letsencrypt:latest
  52. container_name: autoproxy_letsencrypt-updater
  53. volumes:
  54. - letsencrypt-data:/letsencrypt
  55. networks:
  56. - etcd-services
  57. depends_on:
  58. - etcd
  59. # letsencrypt-lexicon obtains Let's Encrypt certificates by modifying
  60. # DNS records. It supports several major cloud DNS providers. You
  61. # need to set the provider and auth tokens below.
  62. letsencrypt-lexicon:
  63. image: csmith/letsencrypt-lexicon:latest
  64. container_name: autoproxy_letsencrypt-lexicon
  65. volumes:
  66. - letsencrypt-data:/letsencrypt
  67. environment:
  68. - STAGING=yes
  69. - EMAIL=your@email.addr
  70. - PROVIDER=cloudflare
  71. - LEXICON_CLOUDFLARE_USERNAME=your@email.addr
  72. - LEXICON_CLOUDFLARE_TOKEN=1234567890123456789012345678901234567890
  73. # letsencrypt-generic uses a user-defined hook to update DNS entries.
  74. # You need to supply your own hook, available at /dns/hook. See the
  75. # letsencrypt.sh repo for details about hook arguments.
  76. #letsencrypt-generic:
  77. # image: csmith/letsencrypt-generic:latest
  78. # volumes:
  79. # - letsencrypt-data:/letsencrypt
  80. # - /my/hook/script:/dns/hook
  81. # environment:
  82. # - STAGING=yes
  83. # - EMAIL=your@email.addr
  84. # service-nginx reads proxy information and vhosts from etcd and
  85. # creates an nginx vhost config to enable SSL-terminated reverse
  86. # proxying to the containers.
  87. nginx-updater:
  88. image: csmith/service-nginx:latest
  89. container_name: autoproxy_nginx-updater
  90. volumes:
  91. - nginx-config:/nginx-config
  92. networks:
  93. - etcd-services
  94. depends_on:
  95. - etcd
  96. # Finally, nginx is what actually does the SSL termination and
  97. # reverse proxying. If any containers to be proxied are on
  98. # non-default networks, you'll need to specify them here and
  99. # below in the top-level networks section.
  100. #
  101. # TODO: Redirect HTTP and add proper SSL options
  102. nginx:
  103. image: nginx:1.9
  104. container_name: autoproxy_nginx
  105. volumes:
  106. - nginx-config:/etc/nginx/conf.d
  107. - letsencrypt-data:/letsencrypt
  108. ports:
  109. - 80:80
  110. - 443:443
  111. networks:
  112. - default
  113. # - mynetwork
  114. # We use inotify-signal-container to monitor for nginx config
  115. # file and SSL cert changes (using inotify) and send nginx a
  116. # SIGHUP signal.
  117. nginx-config-hupper:
  118. image: masm/inotify-signal-container:latest
  119. container_name: autoproxy_nginx-config-hupper
  120. volumes:
  121. - nginx-config:/monitor/nginx
  122. - letsencrypt-data:/monitor/letsencrypt
  123. - /var/run/docker.sock:/var/run/docker.sock
  124. command:
  125. - autoproxy_nginx
  126. - SIGHUP
  127. - /monitor
  128. volumes:
  129. letsencrypt-data:
  130. nginx-config:
  131. networks:
  132. etcd-services:
  133. # To add pre-existing networks, mark them as 'external':
  134. #mynetwork:
  135. # external: true