I have an example project here, that when run using port 80 works as expected. When I change apache's and traefik's port to 8888. Traefik gives me a 'bad gateway' error and logs:
Can anyone have a look to see if they can replicate this/provide me with a solution? My intention is to run apache on non- privileged ports.
Here are the files:
Dockerfile:
FROM php:7.3-apache-stretch
RUN touch /var/www/html/index.html
RUN sed -ri "s!Listen 80!Listen 8888!" /etc/apache2/ports.conf
RUN sed -ri "s!<VirtualHost *:80>!<VirtualHost *:8888>!" /etc/apache2/sites-available/000-default.conf
CMD ["apache2-foreground"]
how is this possible? The webserver is connected to port 8888 and then Traefik is also connected to port 8888:8888 and it has a LoadBalancer service to 8888. In my case this shows an error entryPoint http: error preparing server: error opening listener: listen tcp :8888: bind: address already in use, which makes sense right? it is used by apache so is not possible? Or what am I missing here?
Docker is used. Traefik uses ports to listen on the ports on the host. All other services just listen to the ports within the container connected to the Docker network.
Maybe it’s easier to understand with an explicit Docker network, see simple Traefik example.