# SSL cert for nextcloud docker container

**URL:** <https://help.nextcloud.com/t/ssl-cert-for-nextcloud-docker-container/47521>\
**Category:** 📦 Appliances (Docker, Snappy, VM, NCP, AIO)\
**Created:** [February 13, 2019, 6:47pm UTC](https://help.nextcloud.com/t/ssl-cert-for-nextcloud-docker-container/47521 "2019-02-13T18:47:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bkeating178](https://help.nextcloud.com/letter_avatar/bkeating178/32/5_5575768a8748004e209b776fc1b2916d.png) [@bkeating178](https://help.nextcloud.com/u/bkeating178)\
**Post date:** [February 13, 2019, 6:47pm UTC](https://help.nextcloud.com/t/ssl-cert-for-nextcloud-docker-container/47521/1 "2019-02-13T18:47:49Z")

</div>

I am having issues applying a cert to the nextcloud docker container, I am sure this is not as hard as it seems to be. I have created 2 certs with the below commands and have the apache “default-ssl.conf” file updated accordingly but still, I cannot get the site to load under “https”. I applied this same method to a server build of nextcloud (not a docker container) and it worked perfectly fine.

What I have done (Within the Docker container):  
openssl genrsa -aes128 -out server.key 2048  
openssl rsa -in server.key -out server.key  
openssl req -new -days 3650 -key server.key -out server.csr  
nano /etc/apache2/sites-available/default-ssl.conf

SSLCertificateFile  
/etc/ssl/private/server.crt

SSLCertificateKeyFile  
/etc/ssl/private/server.key

a2ensite default-ssl  
a2enmod ssl

For some reason this does not take from within the docker container.

---

<div class="post-metadata">

**Author:** ![Reiner\_Nippes](https://help.nextcloud.com/user_avatar/help.nextcloud.com/reiner_nippes/32/9479_2.png) [@Reiner\_Nippes](https://help.nextcloud.com/u/Reiner_Nippes)\
**Post date:** [February 13, 2019, 9:43pm UTC](https://help.nextcloud.com/t/ssl-cert-for-nextcloud-docker-container/47521/2 "2019-02-13T21:43:08Z")

</div>

> [@bkeating178](#):
>
> Within the Docker container

never ever do this. unless you don’t mind loosing your certificates when you update your container.  
normally you want to create them on the host and map the folder with “-v /cert/path:/etc/ssl/private”

> [@bkeating178](#):
>
> For some reason

difficult to say without any details. any error message?  
did you expose port 443?

---

<div class="post-metadata">

**Author:** ![bkeating178](https://help.nextcloud.com/letter_avatar/bkeating178/32/5_5575768a8748004e209b776fc1b2916d.png) [@bkeating178](https://help.nextcloud.com/u/bkeating178)\
**Post date:** [February 13, 2019, 10:08pm UTC](https://help.nextcloud.com/t/ssl-cert-for-nextcloud-docker-container/47521/3 "2019-02-13T22:08:09Z")

</div>

@Reiner_Nippes

I will give that a try, and yes I did expose :443. There were no error logs generated as this was an error but rather something that was not working. If I wanted to go the route I mentioned and not worry about updating the container, how would I go about doing that? do you know what I might have done wrong that wouldn’t have allowed my steps to work?

I did the steps mentioned on 2 separate webservers and it worked fine.  
The ultimate goal is to have 2 independent docker containers on 2 independent servers acting as webservers with backend traffic encrypted with low AES128 on the backend for file transfers. Is that even possible with docker?

---

<div class="post-metadata">

**Author:** ![Reiner\_Nippes](https://help.nextcloud.com/user_avatar/help.nextcloud.com/reiner_nippes/32/9479_2.png) [@Reiner\_Nippes](https://help.nextcloud.com/u/Reiner_Nippes)\
**Post date:** [February 14, 2019, 8:37am UTC](https://help.nextcloud.com/t/ssl-cert-for-nextcloud-docker-container/47521/4 "2019-02-14T08:37:06Z")

</div>

> [@bkeating178](#):
>
> how would I go about doing that?

you may look at the [paulczar/omgwtfssl](https://hub.docker.com/r/paulczar/omgwtfssl) docker image. it’s a docker container to generate certificate. additional in the readme you find hints how to use these certificates.

> [@bkeating178](#):
>
> do you know

where did you get the error? blank browser page? browser page saying wrong certificate?

> [@bkeating178](#):
>
> acting as webservers with backend traffic

the docker gurus use [traefik](http://traefik.io/) or nginx (or haproxy) for this purpose.

> [@bkeating178](#):
>
> Is that even possible with docker?

that’s not a docker problem.  
an example setup with traefik in front of several docker container you can find here: [GitHub - ReinerNippes/nextcloud\_on\_docker: Run Nextcloud in Docker Container on various Linux Hosts](https://github.com/ReinerNippes/nextcloud_on_docker)  
some ideas about nextcloud cluster you find here: [Help needed to setup a NC14 cluster - #5 by Finalls](https://help.nextcloud.com/t/help-needed-to-setup-a-nc14-cluster/39707/5)  
everything in the diagram you can put in a docker container.

---

<div class="post-metadata">

**Author:** ![bkeating178](https://help.nextcloud.com/letter_avatar/bkeating178/32/5_5575768a8748004e209b776fc1b2916d.png) [@bkeating178](https://help.nextcloud.com/u/bkeating178)\
**Post date:** [February 15, 2019, 9:32pm UTC](https://help.nextcloud.com/t/ssl-cert-for-nextcloud-docker-container/47521/5 "2019-02-15T21:32:20Z")

</div>

Against your recommendation, I went ahead and applied the cert to the container instead of the server but now I am getting an error message when trying to save the container so I can push it to another server if and when needed. Do you know why this error would be coming up?

Error: Error response from daemon: file integrity checksum failed for “etc/apache2/sites-available/default-ssl.conf”

Command being ran: docker save -o /home/itadmin/sbm\_nextcloud.tar nextcloud

End goal: I am wanting to save a container so I can push a container in the future when needed without losing anything and without having to re-do much configuring on the new VM that I spin up.

Thanks,

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 4, 2024, 9:19am UTC](https://help.nextcloud.com/t/ssl-cert-for-nextcloud-docker-container/47521/6 "2024-12-04T09:19:59Z")

</div>



---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 11, 2024, 2:26pm UTC](https://help.nextcloud.com/t/ssl-cert-for-nextcloud-docker-container/47521/7 "2024-12-11T14:26:48Z")

</div>


