0

I have created a container running apache2 http server, loaded my certificates and https://mydomain works, however http://mydomain works too, and if I digit on my browser mydomain the browser open http://mydomain. Is there a way to disable http protocol? I use only -p 443:443 while starting the container.

This is my Dockerfile

ARG version=2.4.48-alpine

FROM httpd:$version

LABEL version=1.0

COPY ./public_html/ /usr/local/apache2/htdocs/

# run web traffic over SSL/HTTPS

COPY ./cert/srv.crt /usr/local/apache2/conf/
COPY ./cert/srv.key /usr/local/apache2/conf/

RUN ["sed", "-i", "-e", "'s/^#\(Include .*httpd-ssl.conf\)/\1/'", "-e", "'s/^#\(LoadModule .*mod_ssl.so\)/\1/'", "-e", "'s/^#\(LoadModule .*mod_socache_shmcb.so\)/\1/'", "conf/httpd.conf"]


EXPOSE 443/tcp

and this is the outpuf of docker ps:

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                          NAMES
21678d6321e4        webserver           "/bin/sh"           2 hours ago         Up About an hour    80/tcp, 0.0.0.0:443->443/tcp   webserver
Nullndr
  • 1,624
  • 1
  • 6
  • 24
  • 1
    Hi, how is your container configured? Could you edit by putting your sample codes? so we can help better – Henrique Mauri Sep 04 '21 at 13:39
  • could you add the output of `docker ps` command? also your dockerfile or docker-compoe files as well if possible – Noam Yizraeli Sep 04 '21 at 14:30
  • it seems to be a [known issue](https://stackoverflow.com/questions/55917149/docker-container-running-apache-always-exposing-port-80) for httpd image, though is still shouldnt actually publicly publish it... if you stop the container are `http://mydomain` and `https://mydomain` still available? – Noam Yizraeli Sep 04 '21 at 14:49
  • @NoamYizraeli no – Nullndr Sep 04 '21 at 14:53
  • just verifying, none of them correct? – Noam Yizraeli Sep 04 '21 at 15:00
  • @NoamYizraeli yap – Nullndr Sep 04 '21 at 15:11
  • you can rebuild the image using the official repo [dockerfile](https://github.com/docker-library/httpd/blob/208fc2ba9a097530bb0b7386b0c2bebacdfb6c5c/2.4/Dockerfile) and use it instead, though this whole thing is a bit sus – Noam Yizraeli Sep 04 '21 at 15:14

1 Answers1

0

I resolved the issue redirecting http to https exposing also the 80 port.

Nullndr
  • 1,624
  • 1
  • 6
  • 24