-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: add stunnel container image #2110
Open
dcermak
wants to merge
1
commit into
main
Choose a base branch
from
stunnel
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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 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 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 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,80 @@ | ||
# {{ image.pretty_name }} Container Image | ||
|
||
{% include 'badges.j2' %} | ||
|
||
|
||
## Description | ||
|
||
Stunnel is an open-source multi-platform application that provides a universal | ||
TLS/SSL tunneling service. | ||
|
||
|
||
## How to use this image | ||
|
||
By default, the Stunnel container image launches `stunnel` using a minimal | ||
configuration file that specifies the following: | ||
- run in foreground | ||
- load further configuration files from `/etc/stunnel/conf.d` | ||
|
||
Custom configuration files must be placed into the directory | ||
`/etc/stunnel/conf.d`. | ||
|
||
The container entry point configures TLS/SSL automatically by setting the key | ||
and certificate to the values of the environment variables `STUNNEL_KEY` and | ||
`STUNNEL_CERT`. If one of the environment variables is unset, then the | ||
entrypoint defaults to `/etc/stunnel/stunnel.key` for `STUNNEL_KEY` and | ||
`/etc/stunnel/stunnel.pem` for `STUNNEL_CERT`. | ||
|
||
The entrypoint can set up a single service via environment variables, so that | ||
the user doesn't have to write and mount their own configuration file. This can | ||
be specified via the environment variables `STUNNEL_SERVICE_NAME`, | ||
`STUNNEL_ACCEPT` and `STUNNEL_CONNECT`: | ||
|
||
- `STUNNEL_SERVICE_NAME`: name or otherwise unique identifier of the service | ||
(used for documentation purpose only) | ||
|
||
- `STUNNEL_ACCEPT`: address on which new connections should be accepted. It can | ||
be either a hostname and a port number or just a port number (in which case, | ||
localhost is assumed to be the host) | ||
|
||
- `STUNNEL_CONNECT`: address on which the unencrypted service is listening and | ||
to which stunnel connects. It can be either a hostname and port number or just | ||
a port number (in which case, localhost is assumed to be the host) | ||
|
||
|
||
For example, to create an SSL endpoint for a webserver listening on port `8000` | ||
on localhost, run the following command: | ||
|
||
```bash | ||
podman run --rm -d \ | ||
-p 8443:8443 \ | ||
-e STUNNEL_SERVICE_NAME=webserver \ | ||
-e STUNNEL_ACCEPT=0.0.0.0:8443 \ | ||
-e STUNNEL_CONNECT=0.0.0.0:8000 \ | ||
-v=path/to/server.pem:/etc/stunnel/stunnel.pem:Z \ | ||
-v=path/to/server.crt:/etc/stunnel/stunnel.crt:Z \ | ||
{{ image.pretty_reference }} | ||
``` | ||
|
||
|
||
### Logging | ||
|
||
Stunnel supports eight log levels, from 0 (emergency) to 7 (debug) with 5 | ||
(notice) being the default. The log level can be configured via the environment | ||
variable `STUNNEL_DEBUG` using either the number or the log level name. For the | ||
supported logging levels, refer to the [upstream | ||
documentation](https://www.stunnel.org/static/stunnel.html#debug-FACILITY.-LEVEL). | ||
|
||
|
||
### Pitfalls | ||
|
||
The Stunnel container image is configured to launch `stunnel` as the `stunnel` | ||
user. But by default, files mounted into a running container belong to the | ||
`root` user. Set the file permissions of mounted files accordingly, so that | ||
non-owners and non-group members can read them. | ||
|
||
Stunnel's `inetd` mode is not supported in the container image, and it does not | ||
ship a package manager for installing any services. | ||
|
||
|
||
{% include 'licensing_and_eula.j2' %} |
This file contains 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,24 @@ | ||
#!/bin/bash | ||
|
||
set -eo pipefail | ||
|
||
STUNNEL_CERT="${STUNNEL_CERT:-/etc/stunnel/stunnel.pem}" | ||
STUNNEL_KEY="${STUNNEL_KEY:-/etc/stunnel/stunnel.key}" | ||
|
||
if [[ -n ${STUNNEL_DEBUG} ]]; then | ||
echo "debug = ${STUNNEL_DEBUG}" > /etc/stunnel/conf.d/000debug.conf | ||
fi | ||
|
||
conf="/etc/stunnel/conf.d/container-ssl.conf" | ||
echo "cert = ${STUNNEL_CERT}" > $conf | ||
echo "key = ${STUNNEL_KEY}" >> $conf | ||
|
||
|
||
if [[ -n "${STUNNEL_SERVICE_NAME}" ]] && [[ -n "${STUNNEL_ACCEPT}" ]] && [[ -n "${STUNNEL_CONNECT}" ]]; then | ||
conf="/etc/stunnel/conf.d/container.conf" | ||
echo "[${STUNNEL_SERVICE_NAME}]" > $conf | ||
echo "accept = ${STUNNEL_ACCEPT}" >> $conf | ||
echo "connect = ${STUNNEL_CONNECT}" >> $conf | ||
fi | ||
|
||
exec "$@" |
This file contains 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,2 @@ | ||
foreground = yes | ||
include = /etc/stunnel/conf.d |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please create a separate stunnel.py toplevel and not add further containers to appcontainers (I apologize for having started this, we definitely shouldn't continue with it)