-
Notifications
You must be signed in to change notification settings - Fork 88
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
Allow custom paths for certificates #36
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ FROM sillelien/base-alpine:0.10 | |
MAINTAINER Zhuohuan LI <[email protected]> | ||
|
||
ENV BATS_VERSION 0.4.0 | ||
ENV DOCKERIZE_VERSION v0.6.0 | ||
|
||
## Install System | ||
|
||
|
@@ -19,11 +20,19 @@ RUN apk update && apk add \ | |
&& tar -xzf "/tmp/v${BATS_VERSION}.tar.gz" -C /tmp/ \ | ||
&& bash "/tmp/bats-${BATS_VERSION}/install.sh" /usr/local \ | ||
\ | ||
&& wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ | ||
&& tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ | ||
&& rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ | ||
\ | ||
&& rm -rf /var/cache/apk/* && rm -rf /tmp/* | ||
|
||
|
||
## Configure Service | ||
|
||
COPY install/main.dist.cf /etc/postfix/main.cf | ||
ENV CERTIFICATE_PUBLIC=/etc/postfix/cert/smtp.cert | ||
ENV CERTIFICATE_PRIVATE=/etc/postfix/cert/smtp.key | ||
|
||
COPY install/main.dist.cf.tmpl /etc/postfix/main.cf.tmpl | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to overwrite this file( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By default the content of the expanded main.cf will be "overwritten" because the location of /etc/postfix is not mounted as a volume, hence it will be lost between restarts. But if the user mounts the |
||
COPY install/master.dist.cf /etc/postfix/master.cf | ||
|
||
RUN cat /dev/null > /etc/postfix/aliases && newaliases \ | ||
|
@@ -53,6 +62,8 @@ COPY .git/logs/HEAD /app/GIT_LOG | |
COPY .git/HEAD /app/GIT_HEAD | ||
COPY install/buildenv.sh /app/ | ||
|
||
RUN rm /etc/postfix/main.cf | ||
|
||
VOLUME ["/var/spool/postfix"] | ||
|
||
EXPOSE 25 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ This docker was built for ultimate **simplicity** because of this reason. I owne | |
|
||
### Related Services | ||
- [DuoCircle Email Forwarding](http://www.duocircle.com/services/email-forwarding) From $59.95/year | ||
- [Cloud Mail In](https://www.cloudmailin.com/plans) From $9/month. And it is not for human. | ||
- [Cloud Mail In](https://www.cloudmailin.com/plans) From $9/month. And it is not for human. | ||
- [MailGun](https://mailgun.com) professional service. Free plan includes 10,000 emails/month. but [can result in your domain being treated as spam](https://blog.rajivm.net/mailgun-forwarding-spam.html) | ||
|
||
I was willing to pay $10/year, but the cheapest plan I could find was $9 per month. Having a $10 USD machine with unlimited mail&domains per month is an amazing idea! And of couse you could also put other dockers on this same machine. :-D | ||
|
@@ -57,7 +57,7 @@ If you want to forward all emails sent to domain testo.com to [email protected], set | |
$ export SMF_CONFIG='@testo.com:[email protected]' | ||
``` | ||
|
||
See? There is nothing easier. | ||
See? There is nothing easier. | ||
|
||
> If you want to run it constanly in the background add ` -td` after `run`: | ||
```bash | ||
|
@@ -149,20 +149,30 @@ Send all outgoing mail trough a smarthost on 192.168.1.2 | |
$ export SMF_RELAYHOST='192.168.1.2' | ||
``` | ||
|
||
### `CERTIFICATE_PUBLIC`, `CERTIFICATE_PRIVATE` Examples | ||
|
||
Path of the certificate and private key. Defaults: | ||
|
||
* `CERTIFICATE_PUBLIC` = `/etc/postfix/cert/smtp.cert` | ||
* `CERTIFICATE_PRIVATE` = `/etc/postfix/cert/smtp.key` | ||
|
||
**Note:** Although full paths are specified for each file they must be in the same directory. | ||
|
||
If files do no exist on boot a self signed certificate is created. Read the following section for more information. | ||
|
||
TLS (SSL) Certificates | ||
-------------------- | ||
SMF creates its own certificate and private key when starts. However, this certificate is self signed and so some systems might give you a warning about the server not being trusted. | ||
If you have valid certificates for the domain name of the host, then you can use them and avoid the warning about not being trusted. | ||
|
||
1. First you need to prepare the certificate files. Copy your full chain certificate to a file named `smtp.cert`. Then copy the private key to a file named `smtp.key` | ||
|
||
2. Copy these files to a folder. For example: `/data/certs/`. This folder will be mounted as a volume in SMF | ||
1. First you need to prepare the certificate files. Identify your full chain certificate and private key. They are usually next to each other. Mount the directory for example at `/data/certs`. Let's assume `/data/certs/smtp.cert` is the full chain certificat and `/data/certs/smtp.key` is the private key in your host running docker. | ||
|
||
3. When creating the container, add the `-v` (volume) parameter to mount it to the folder `/etc/postfix/cert/` like so: | ||
2. When creating the container, add the `-v` (volume) parameter to mount as a folder `/certificate` and specify the path of them in the container like so: | ||
```bash | ||
$ docker run -e SMF_CONFIG="$SMF_CONFIG" -p 25:25 -v /data/certs/:/etc/postfix/cert/ zixia/simple-mail-forwarder | ||
$ docker run -e SMF_CONFIG="$SMF_CONFIG" -e CERTIFICATE_PUBLIC="/certificate/smtp.cert" -e CERTIFICATE_PRIVATE="/certificate/smtp.key" -p 25:25 -v /data/certs:/certificate zixia/simple-mail-forwarder | ||
``` | ||
4. Your emails should now be forwarded with trusted encryption. You can use this tool to test it: <a href="http://checktls.com/" target="_blank">http://checktls.com/</a> | ||
|
||
3. Your emails should now be forwarded with trusted encryption. You can use this tool to test it: <a href="http://checktls.com/" target="_blank">http://checktls.com/</a> | ||
|
||
If you do not have a certificate and don't have the $$ to buy one, you can use <a href="https://letsencrypt.org" target="_blank">https://letsencrypt.org</a> if you have shell access to the server (Notice, SMF does not provide, yet, this service). Letsencrypt allows you to create valid trusted certificates for a server, if the server responds to the domain you specify. In order to do this, you need to run the program from within the server and have administrator rights. | ||
|
||
|
@@ -179,9 +189,10 @@ If you do not have a certificate and don't have the $$ to buy one, you can use < | |
```bash | ||
$ letsencrypt certonly --standalone -d yourdomain.com -d www.yourdomain.com -d mail.yourdomain.com | ||
``` | ||
5. Follow the prompts and if everything is successful you will get your certificates in a folder like `/etc/letsencrypt/live/mydomain.com` | ||
|
||
6. You can now use those certificates to make SMF TLS trusted. | ||
5. Follow the prompts and if everything is successful you will get your certificates in a folder like `/etc/letsencrypt/live/mydomain.com`. | ||
|
||
6. You can now use those certificates to make SMF TLS trusted. You will need to use `fullchain.pem` and `privkey.pem` as the certificate and private key respectively. | ||
|
||
> This was a quick way of how to use letsencrypt. For a full tutorial based on your OS see: <a href="https://certbot.eff.org/" tareget="_blank">https://certbot.eff.org/</a> | ||
|
||
|
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.
Can we support inline data here?
For example:
This would be able to let me set it in docker cloud web manager directly, without care about any files.
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.
It would be a bit hacky probably. How would you differentiate between a path and inline data? Because it starts with a
/
? I would rather use another variable and in theinit-openssl.sh
echo aCERTIFICATE_PUBLIC_PAYLOAD
to theCERTIFICATE_PUBLIC
path. Same with private.It's rare that both
CERTIFICATE_PUBLIC
andCERTIFICATE_PUBLIC_PAYLOAD
be defined at the same time. But I think different variables would end up in cleaner expectation.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.
On more thought, is it realistic to manually edit the certificate content? In my use case either in docker cloud or in rancher a letsencrypt container periodically renew the certificate. Been able to mount the output as is in the smf container is enough to keep things working.
If a renewal of the certificate is the motivation for this, it will force you to manually be involved.
And on other side, isn't it to risky to allow save the private key in the database of the docker cloud manager you use?
I think that easy manual editing of the content of the certificate can be obtained by this PR as is plus using for example https://filebrowser.github.io/ which can be used as a docker container and has inline file editing.