简体   繁体   中英

HTTPS server in Docker container

I have a problem about how to deploy https server in docker. It failed to access the content due to SSL error. And then I did an experiment to test SSL function in docker container. The experiment is to listen on a port (tls), and if a connection comes then send back the content of a file.

My Dockerfile is like:

FROM ruanhao/centos-dev
EXPOSE 8443
COPY banner .
COPY server.crt.pem .
COPY server.key.pem .
CMD socat -U openssl-listen:8443,reuseaddr,cert=server.crt.pem,key=server.key.pem,verify=0,fork open:banner

And I run the docker as docker run -d -p 8443:8443 --name tls -it ruanhao/socat-tls

Then I used curl to get the content. curl -k -v -L https://192.168.99.100:8443 , but it failed:

* Rebuilt URL to: https://192.168.99.100:8443/
*   Trying 192.168.99.100...
* Connected to 192.168.99.100 (192.168.99.100) port 8443 (#0)
* Unknown SSL protocol error in connection to 192.168.99.100:-9850
* Closing connection 0
curl: (35) Unknown SSL protocol error in connection to 192.168.99.100:-9850

I don't know why it is like this. Is there something I do not know about the usage of TLS in docker? Do you know how to fix it? Thank you.

Dockerfile

ADD ./apache.conf /etc/apache2/sites-enabled/000-default.conf
ADD ./ssl/ /ssl/
RUN a2enmod ssl
CMD service apache2 start 

ssl folder contains server.key & server.key files.

apache

<virtualHost _default_:443>

DocumentRoot "/var/www/"

SSLEngine on
SSLCertificateFile /ssl/server.crt
SSLCertificateKeyFile /ssl/server.key
</VirtualHost>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM