Skip to content

Commit 478a423

Browse files
Merge pull request #1 from philippe-vandermoere/feature-init
init project
2 parents e738f92 + 3b8124f commit 478a423

File tree

5 files changed

+224
-1
lines changed

5 files changed

+224
-1
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.env
2+
/.idea/
3+

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Philippe VANDERMOERE
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 98 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,98 @@
1-
# docker-proxy
1+
# Docker-proxy
2+
3+
A HTTP reverse proxy for docker.
4+
5+
## Requirements
6+
7+
- [Docker](https://docs.docker.com/install/#supported-platforms) >= 18.09.6
8+
- [Docker compose](https://docs.docker.com/compose/install) >= 1.24.0
9+
10+
## External dependency
11+
12+
Web server:
13+
- [Nginx](https://github.com/philippe-vandermoere/docker-proxy-nginx)
14+
15+
The web server is automatically configure when you add/remove a container by one of this provider
16+
- [PHP](https://github.com/philippe-vandermoere/docker-proxy-php)
17+
- [GO](https://github.com/philippe-vandermoere/docker-proxy-go) (experimental)
18+
19+
## Installation
20+
21+
```bash
22+
git clone https://github.com/philippe-vandermoere/docker-proxy
23+
docker-proxy/start.sh
24+
```
25+
26+
The script:
27+
- Ask you to configure docker-proxy:
28+
- `HTTP_PORT`: Define the listen http port of proxy (default 80).
29+
- `HTTPS_PORT`: Define the listen https port of proxy (default 443).
30+
- `NGINX_VERSION`: Define the version of nginx service (default latest).
31+
- `PROXY_PROVIDER`: Define the provider of proxy (default php).
32+
- `PROXY_PROVIDER_VERSION`: Define The version of provider of proxy (default latest).
33+
34+
- Start the stack
35+
36+
You can see the list of containers managed by proxy on http://127.0.0.1:${HTTP_PORT}
37+
38+
## Container configuration
39+
40+
### General configuration
41+
42+
- `com.docker-proxy.domain`: Define the domain of your service (require).
43+
- `com.docker-proxy.port`: Define the http port of your service (default 80).
44+
- `com.docker-proxy.path`: Define the domain path of your service (default /).
45+
- `com.docker-proxy.sslcom.docker-proxy.ssl`: Define if you need https (default: false).
46+
47+
### Certificate provider Configuration
48+
49+
#### Github
50+
51+
- `com.docker-proxy.certificate-provider.name`: Define the provider name (require github).
52+
- `com.docker-proxy.certificate-provider.token`: Define the github token (require).
53+
- `com.docker-proxy.certificate-provider.repository`: Define the github repository (require).
54+
- `com.docker-proxy.certificate-provider.reference`: Define the git reference (default: master).
55+
- `com.docker-proxy.certificate-provider.certificate_path`: Define the path of certificate (require).
56+
- `com.docker-proxy.certificate-provider.private_key_path`: Define the path of private key (require).
57+
58+
### Examples
59+
60+
#### HTTP
61+
62+
```docker
63+
version: '3.5'
64+
services:
65+
nginx:
66+
image: nginx:1.16.0-alpine
67+
labels:
68+
com.docker-proxy.domain: test.loc
69+
```
70+
71+
#### HTTPS generate self-signed certificate
72+
73+
```docker
74+
version: '3.5'
75+
services:
76+
nginx:
77+
image: nginx:1.16.0-alpine
78+
labels:
79+
com.docker-proxy.domain: test.loc
80+
com.docker-proxy.ssl: true
81+
```
82+
83+
#### HTTPS download certificate from github
84+
85+
```docker
86+
version: '3.5'
87+
services:
88+
nginx:
89+
image: nginx:1.16.0-alpine
90+
labels:
91+
com.docker-proxy.domain: test.loc
92+
com.docker-proxy.ssl: true
93+
com.docker-proxy.certificate-provider.name: github
94+
com.docker-proxy.certificate-provider.token: {github_token}
95+
com.docker-proxy.certificate-provider.repository: {github_orga}/{github_repository}
96+
com.docker-proxy.certificate-provider.certificate_path: {github_certificate_path}
97+
com.docker-proxy.certificate-provider.private_key_path: {github_private_key_path}
98+
```

docker-compose.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
version: '3.5'
2+
services:
3+
nginx:
4+
container_name: docker-proxy-nginx
5+
image: philippev/docker-proxy-nginx:${NGINX_VERSION:-latest}
6+
restart: unless-stopped
7+
ports:
8+
- ${HTTP_PORT:-80}:80
9+
- ${HTTPS_PORT:-443}:443
10+
volumes:
11+
- virtual_host:/etc/nginx/conf.d
12+
- homepage:/var/www/homepage
13+
- certificates:/etc/nginx/certificates:ro
14+
15+
proxy:
16+
container_name: docker-proxy-cli
17+
image: philippev/docker-proxy-${PROXY_PROVIDER:-php}:${PROXY_PROVIDER_VERSION:-latest}
18+
restart: unless-stopped
19+
environment:
20+
HTTP_PORT: ${HTTP_PORT:-80}
21+
HTTPS_PORT: ${HTTPS_PORT:-443}
22+
VIRTUAL_HOST_DIRECTORY: /etc/nginx/conf.d
23+
HOMEPAGE_DIRECTORY: /var/www/homepage
24+
CERTIFICATE_DIRECTORY: /etc/nginx/certificates
25+
volumes:
26+
- /var/run/docker.sock:/var/run/docker.sock
27+
- virtual_host:/etc/nginx/conf.d
28+
- homepage:/var/www/homepage
29+
- certificates:/etc/nginx/certificates
30+
31+
volumes:
32+
virtual_host:
33+
homepage:
34+
certificates:

start.sh

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
readonly CURRENT_DIRECTORY=$(pwd)
6+
readonly SCRIPT_DIRECTORY=$(dirname $(realpath $0))
7+
8+
# PROMPT COLOURS
9+
readonly RESET='\033[0;0m'
10+
readonly BLACK='\033[0;30m'
11+
readonly RED='\033[0;31m'
12+
readonly GREEN='\033[0;32m'
13+
readonly YELLOW='\033[0;33m'
14+
readonly BLUE='\033[0;34m'
15+
readonly PURPLE='\033[0;35m'
16+
readonly CYAN='\033[0;36m'
17+
18+
function ask_value() {
19+
local message=$1
20+
local default_value=$2
21+
local value
22+
local default_value_message=''
23+
24+
if [[ ! -z ${default_value} ]]; then
25+
default_value_message=" (default: ${YELLOW}${default_value}${CYAN})"
26+
fi
27+
28+
echo -en "${CYAN}${message}${default_value_message}:${RESET} " > /dev/tty
29+
read value
30+
31+
if [[ -z ${value} ]]; then
32+
if [[ -z ${default_value} ]]; then
33+
value=$(ask_value "${message}")
34+
else
35+
value="${default_value}"
36+
fi
37+
fi
38+
39+
echo "${value}"
40+
}
41+
42+
http_port=$(ask_value "Define the HTTP PORT" 80)
43+
44+
https_port=$(ask_value "Define the HTTPS PORT" 443)
45+
46+
echo -e "${YELLOW}List of Nginx version https://hub.docker.com/r/philippev/docker-proxy-nginx/tags${RESET}"
47+
nginx_version=$(ask_value "Define the version of Nginx proxy" latest)
48+
49+
proxy_provider=$(ask_value "Choose proxy configurator provider (php|go)" php)
50+
51+
if [[ "${proxy_provider}" != "php" ]] && [[ "${proxy_provider}" != "go" ]]; then
52+
echo "${RED}The proxy configurator must be php or go.${RESET}"
53+
exit 1
54+
fi
55+
56+
echo -e "${YELLOW}List of ${proxy_provider} version https://hub.docker.com/r/philippev/docker-proxy-${proxy_provider}/tags${RESET}"
57+
proxy_provider_version=$(ask_value "Define the version of proxy configurator ${proxy_provider}" latest)
58+
59+
echo "COMPOSE_PROJECT_NAME=docker-proxy" > ${SCRIPT_DIRECTORY}/.env
60+
echo "HTTP_PORT=${http_port}" >> ${SCRIPT_DIRECTORY}/.env
61+
echo "HTTPS_PORT=${https_port}" >> ${SCRIPT_DIRECTORY}/.env
62+
echo "NGINX_VERSION=${nginx_version}" >> ${SCRIPT_DIRECTORY}/.env
63+
echo "PROXY_PROVIDER=${proxy_provider}" >> ${SCRIPT_DIRECTORY}/.env
64+
echo "PROXY_PROVIDER_VERSION=${proxy_provider_version}" >> ${SCRIPT_DIRECTORY}/.env
65+
66+
cd ${SCRIPT_DIRECTORY}
67+
docker-compose up --detach --renew-anon-volumes --remove-orphans
68+
cd ${CURRENT_DIRECTORY}

0 commit comments

Comments
 (0)