Skip to content
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

Need Help/suggestions to add signed certificate #45

Open
niteenkole opened this issue Jun 1, 2021 · 1 comment
Open

Need Help/suggestions to add signed certificate #45

niteenkole opened this issue Jun 1, 2021 · 1 comment

Comments

@niteenkole
Copy link

Hi,

Works fine

docker run -dt -p 8000:80 -v /data/niteen-docs/grav_docs:/var/www/html grav:09

Now I need to add my signed certificates any help appreciated.

@sesquipedality
Copy link

sesquipedality commented Jul 8, 2021

Hi

Here is a diff for the Dockerfile provided to do SSL

--- Dockerfile.orig     2021-07-08 18:00:40.447254308 +0100
+++ Dockerfile  2021-07-08 18:40:11.896558852 +0100
@@ -70,6 +70,14 @@
 # Copy init scripts
 # COPY docker-entrypoint.sh /entrypoint.sh

+# Add SSL support
+RUN a2enmod ssl
+RUN sed -i "s_/etc/ssl/certs/ssl-cert-snakeoil.pem_/etc/ssl/apache/cert.pem_" /etc/apache2/sites-available/default-ssl.conf
+RUN sed -i "s_/etc/ssl/private/ssl-cert-snakeoil.key_/etc/ssl/apache/privkey.pem_" /etc/apache2/sites-available/default-ssl.conf
+RUN cd /etc/apache2/sites-enabled && ln -s ../sites-available/default-ssl.conf default-ssl.conf
+RUN rm /etc/apache2/sites-enabled/000-default.conf
+VOLUME ["/etc/ssl/apache"]
+
 # provide container inside image for data persistence
 VOLUME ["/var/www/html"]

(There is a blank line on the end of the diff file.)

This assumes you are storing your keys in the root of a volume as "privkey.pem" and "cert.pem" which will be mounted on /etc/ssl/apache in the docker image.

This will provide https on internal port 443. If you want to keep providing http on Port 80, comment out the line beginning "+RUN rm".

You will probably need to set "hostname" to match your SSL keys in docker-compose.yml as well.

(Please note the original version of this patch used /etc/ssl. This was not a good idea as it overwrote the root certificates. I have therefore amended this post and replaced rather than creating an update.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants