|
1 |
| -# Usage of Docker Compose (docker-compose) with NGINX Proxy and Letsencrypt |
| 1 | +# A Web Proxy using Docker, NGINX and Let's Encrypt |
2 | 2 |
|
3 |
| -Docker Compose (docker-compose) for [docker-letsencrypt-nginx-proxy-companion](https://github.com/JrCs/docker-letsencrypt-nginx-proxy-companion) |
| 3 | +With this repo you will be able to set up your server with multiple sites using a single NGINX proxy to manage your connections. |
4 | 4 |
|
| 5 | +Something like: |
5 | 6 |
|
6 |
| -## Purpose |
| 7 | + |
7 | 8 |
|
8 |
| -This docker-compose file, version '3', was built to help using NGINX as web proxy to your containers, integrated with LetsEncrypt certification, using the great work of [@jwilder](https://github.com/jwilder) with [docker-gen](https://github.com/jwilder/docker-gen) and [nginx-proxy](https://github.com/jwilder/nginx-proxy) along with the ultimate tool [docker-letsencrypt-nginx-proxy-companion](https://github.com/JrCs/docker-letsencrypt-nginx-proxy-companion) designed by [JrCs](https://github.com/JrCs) to integrate the great SSL Certificates from the best [LetsEncrypt](https://letsencrypt.org/). |
9 | 9 |
|
| 10 | +## Why use it? |
10 | 11 |
|
11 |
| -## Usage |
| 12 | +Using this set up you will be able start a productyion enviornment in a few seconds. And to start new web project simply start new containers the option `-e VIRTUAL_HOST=your.domain.com` and will be ready to go, if you want to use SSL (Let's Encrypt) just add the tag `-e LETSENCRYPT_HOST=your.domain.com`. Done! |
12 | 13 |
|
13 |
| -In order to use, you must follow these steps: |
| 14 | +Easy and trustworthy! |
14 | 15 |
|
15 |
| -1. Clone this repository: |
16 | 16 |
|
17 |
| -```bash |
18 |
| -git clone https://github.com/evertramos/webproxy.git |
19 |
| -``` |
| 17 | +## Prerequisites |
| 18 | + |
| 19 | +In order to use this compose file (docker-compose.yml) you must have: |
20 | 20 |
|
21 |
| -Or just copy the content of `docker-compose.yml`, as of below and substitute with your own configuration settings: |
| 21 | +1. docker (https://docs.docker.com/engine/installation/) |
| 22 | +2. docker-compose (https://docs.docker.com/compose/install/) |
| 23 | + |
| 24 | + |
| 25 | +## How to use it |
| 26 | + |
| 27 | +1. Clone this repository: |
22 | 28 |
|
23 | 29 | ```bash
|
24 |
| -version: '3' |
25 |
| -services: |
26 |
| - nginx: |
27 |
| - image: nginx |
28 |
| - labels: |
29 |
| - com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: "true" |
30 |
| - container_name: ${NGINX_WEB} |
31 |
| - restart: unless-stopped |
32 |
| - ports: |
33 |
| - - "${IP}:80:80" |
34 |
| - - "${IP}:443:443" |
35 |
| - volumes: |
36 |
| - - ${NGINX_FILES_PATH}/conf.d:/etc/nginx/conf.d |
37 |
| - - ${NGINX_FILES_PATH}/vhost.d:/etc/nginx/vhost.d |
38 |
| - - ${NGINX_FILES_PATH}/html:/usr/share/nginx/html |
39 |
| - - ${NGINX_FILES_PATH}/certs:/etc/nginx/certs:ro |
40 |
| - |
41 |
| - nginx-gen: |
42 |
| - image: jwilder/docker-gen |
43 |
| - command: -notify-sighup nginx -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf |
44 |
| - container_name: ${DOCKER_GEN} |
45 |
| - restart: unless-stopped |
46 |
| - volumes: |
47 |
| - - ${NGINX_FILES_PATH}/conf.d:/etc/nginx/conf.d |
48 |
| - - ${NGINX_FILES_PATH}/vhost.d:/etc/nginx/vhost.d |
49 |
| - - ${NGINX_FILES_PATH}/html:/usr/share/nginx/html |
50 |
| - - ${NGINX_FILES_PATH}/certs:/etc/nginx/certs:ro |
51 |
| - - /var/run/docker.sock:/tmp/docker.sock:ro |
52 |
| - - ./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro |
53 |
| - |
54 |
| - nginx-letsencrypt: |
55 |
| - image: jrcs/letsencrypt-nginx-proxy-companion |
56 |
| - container_name: ${LETS_ENCRYPT} |
57 |
| - restart: unless-stopped |
58 |
| - volumes: |
59 |
| - - ${NGINX_FILES_PATH}/conf.d:/etc/nginx/conf.d |
60 |
| - - ${NGINX_FILES_PATH}/vhost.d:/etc/nginx/vhost.d |
61 |
| - - ${NGINX_FILES_PATH}/html:/usr/share/nginx/html |
62 |
| - - ${NGINX_FILES_PATH}/certs:/etc/nginx/certs:rw |
63 |
| - - /var/run/docker.sock:/var/run/docker.sock:ro |
64 |
| - environment: |
65 |
| - NGINX_DOCKER_GEN_CONTAINER: ${DOCKER_GEN} |
66 |
| - NGINX_PROXY_CONTAINER: ${NGINX_WEB} |
67 |
| - |
68 |
| -networks: |
69 |
| - default: |
70 |
| - external: |
71 |
| - name: ${NETWORK} |
| 30 | +git clone https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion.git |
72 | 31 | ```
|
73 | 32 |
|
74 |
| -2. Create an `.env` file as of our `.env.sample`, save it in the same folder as your compose file: |
| 33 | +2. Make a copy of our `.env.sample` and rename it to `.env`: |
| 34 | + |
| 35 | +Update this file with your preferences. |
75 | 36 |
|
76 | 37 | ```
|
77 | 38 | #
|
@@ -105,9 +66,16 @@ NGINX_FILES_PATH=/path/to/your/nginx/data
|
105 | 66 |
|
106 | 67 | Your proxy is ready to go!
|
107 | 68 |
|
| 69 | +5. Test your proxy |
| 70 | + |
| 71 | +```bash |
| 72 | + docker run -dit -e VIRTUAL_HOST=your.domain.com --network=webproxy --name test-web httpd:alpine |
| 73 | +``` |
| 74 | + |
| 75 | +And access your browser with your domain already configured in your dns. |
108 | 76 |
|
109 |
| -> Please note that when running a new container to generate certificates with LetsEncrypt it may take a few minutes, depending on multiples circunstances. |
110 | 77 |
|
| 78 | +> Please note that when running a new container to generate certificates with LetsEncrypt (`-e LETSENCRYPT_HOST=your.domain.com`), it may take a few minutes, depending on multiples circunstances. |
111 | 79 |
|
112 | 80 |
|
113 | 81 | ## Next Step
|
|
0 commit comments