This repository was archived by the owner on Aug 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
21b5f25
Add mkcert for certificates
arnested 7c18b1c
Add certificate to folder in format recognizable by Dory / nginx-ssl
arnested ea9f95f
Locate CA root in away that is preconfigured to work on both Mac and …
arnested 3dc3721
Add documentation on how to integrate the mkcert support with Dory
danquah 84b752d
Create expected foldes in Dockerfile
arnested 4d8cff9
Improve documentation on mkcert part
arnested 1b72b0d
Support Dinghy wildcard domains
arnested fc418de
Add more documentation to mkcert.sh script
arnested 0d1cd2f
Be verbose about copying into /cert
arnested File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,89 @@ | ||
# Apache FPM container based on phusion | ||
Simple apache-vhost that serves content from /var/www/web - php-requests are | ||
proxied to a linked fpm-container named "fpm" on port 9000. | ||
|
||
|
||
# Dory | ||
|
||
Use the following if you use [dory](https://github.com/FreedomBen/dory) (much of the same applies for [nginx-proxy](https://github.com/jwilder/nginx-proxy) and [dinghy-http-proxy](https://github.com/codekitchen/dinghy-http-proxy) which Dory is based on). | ||
|
||
```yaml | ||
environment: | ||
VIRTUAL_HOST: example.docker | ||
VIRTUAL_PORT: 80 | ||
# Use the following if you want to handle redirects from http to https yourself. | ||
HTTPS_METHOD: noredirect | ||
|
||
``` | ||
|
||
## Using autogenerated certificates | ||
This require Dory version 1.0.3, use `dory upgrade` to upgrade | ||
|
||
If you don't already have a Dory configuration-file, have it generate one by running `dory config` then update the update `ssl_certs_dir` configuration: | ||
|
||
```yaml | ||
nginx_proxy: | ||
enabled: true | ||
container_name: dory_dinghy_http_proxy | ||
https_enabled: true | ||
# Update the follow line to point at the dev_certificates | ||
ssl_certs_dir: <your homedir>/.local/share/dev_certificates | ||
``` | ||
|
||
Then mount that directory into the apache-fpm container so that its auto-generated certificates will be accessible to Dory. | ||
|
||
```yaml | ||
volumes: | ||
- '${HOME}/.local/share/dev_certificates:/cert:rw' | ||
``` | ||
|
||
Then follow the steps in the mkcert sections to specify which certificates to generate and have your OS trust them. | ||
|
||
# mkcert | ||
|
||
This image has [mkcert](https://github.com/FiloSottile/mkcert) | ||
builtin. | ||
|
||
Install `mkcert` on your host machine and generate and install a root | ||
certificate by running `mkcert -install` on your host machine. | ||
|
||
Then you add the generated CAROOT as a volume (the path on the host | ||
machine is the output of `mkcert -CAROOT`). | ||
|
||
In your `docker-compose.yml` supply one or more host names to be be | ||
used for HTTPS. Host names will be search for in these location and in | ||
this order: | ||
|
||
1. environment variable `MKCERT_DOMAINS` (several hostnames separated | ||
by space is possible, you can even supply a wildcard domain), | ||
1. the environment variable `VIRTUAL_HOST` (as used by [Dinghy HTTP | ||
Proxy](https://github.com/codekitchen/dinghy-http-proxy)), or | ||
1. the output of `hostname -f` in the container (which can be set with | ||
the `hostname` and `domainname` options). | ||
|
||
```yaml | ||
volumes: | ||
- '${HOME}/Library/Application Support/mkcert:/mkcert/mac:ro' | ||
- '${HOME}/.local/share/mkcert:/mkcert/linux:ro' | ||
|
||
environment: | ||
MKCERT_DOMAINS: "example.docker *.example.docker local.docker" | ||
|
||
hostname: example | ||
domainname: docker | ||
``` | ||
|
||
# Full example configuration | ||
|
||
```yaml | ||
volumes: | ||
- '${HOME}/Library/Application Support/mkcert:/mkcert/mac:ro' | ||
- '${HOME}/.local/share/mkcert:/mkcert/linux:ro' | ||
- '${HOME}/.local/share/dev_certificates:/cert:rw' | ||
|
||
environment: | ||
MKCERT_DOMAINS: "example.docker *.example.docker local.docker" | ||
VIRTUAL_HOST: example.docker | ||
VIRTUAL_PORT: 80 | ||
HTTPS_METHOD: noredirect | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
# Try to locate `rootCA.pem` and `rootCA-key.pem` in a folder beneath | ||
# `/mkcert`. | ||
CAROOT="$(find /mkcert -type d -exec sh -c '[ -f "$0"/rootCA.pem ] && [ -f "$0"/rootCA-key.pem ]' '{}' \; -print)" | ||
export CAROOT | ||
|
||
# If no root CA found just exit now without generating any | ||
# certificates. | ||
if [[ -z "${CAROOT}" ]]; then | ||
exit 0; | ||
fi | ||
|
||
# If no VIRTUAL_HOST is set use `hostname -f` as fallback. | ||
VIRTUAL_HOST="${VIRTUAL_HOST:-$(hostname -f)}" | ||
|
||
# Dinghys wildcard syntax is prefixing only with a dot (as in | ||
# `.example.com`). We rewrite those to use an asterisk as expected by | ||
# mkcert (`*.example.com`). | ||
VIRTUAL_HOST="${VIRTUAL_HOST/#./*.}" | ||
|
||
# If on MKCERT_DOMAINS is set use VIRTUAL_HOST as fallback. | ||
MKCERT_DOMAINS="${MKCERT_DOMAINS:-${VIRTUAL_HOST}}" | ||
|
||
# If we couldn't find any domain names just exit now without | ||
# generating any certificates. | ||
if [[ -z "${MKCERT_DOMAINS}" ]]; then | ||
exit 0; | ||
fi | ||
|
||
# Split a space separated string into a bash array. | ||
IFS=' ' read -r -a MKCERT_DOMAINS <<< "${MKCERT_DOMAINS}" | ||
|
||
# Install the CA certificate in the Docker containers system trust | ||
# store. Mostly we do that to ignore warnings about the CA not being | ||
# installed when generating certificates later (but also to trust the | ||
# certificates from within). | ||
/usr/local/bin/mkcert -install | ||
|
||
# Run `mkcert` to generate certificate and key. | ||
/usr/local/bin/mkcert -cert-file /etc/ssl/certs/ssl-cert-snakeoil.pem -key-file /etc/ssl/private/ssl-cert-snakeoil.key "${MKCERT_DOMAINS[@]}" | ||
|
||
# Expose the generated certificate in /cert named after the first | ||
# domain name (compatible with Dory / nginx-proxy). | ||
echo "Copying certficate(s) and key(s) into /cert:" | ||
for domain in "${MKCERT_DOMAINS[@]}" | ||
do | ||
# Strip wildcard. | ||
domain="${domain#\*\.}" | ||
cp -v /etc/ssl/certs/ssl-cert-snakeoil.pem "/cert/${domain}.crt" | ||
cp -v /etc/ssl/private/ssl-cert-snakeoil.key "/cert/${domain}.key" | ||
done |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.