Docker apache2 keeps showing 502 Bad Request

Hi, my name is EisKaffe, I am a complete beginner with Docker, I have this Docker project whose architect has recently changed the apache image thus making my app unusable displaying 502 Bad Gateway all the time. Please help me figure out what might be the problem. This is my docker-compose.yml :

version: '3.8'

services:
  apache:
    image: 'docker-registry.teralab.com/my-robot:aio-20211112'
    volumes:
      - /mnt/c/dev/my-common:/my-common
      - /mnt/c/dev/teralabsoft-robot:/web
      - ./logs:/var/log/apache2
      - ./logs:/var/log/php
      - ./apache2:/usr/local/apache2/conf:ro
      - ./odbcinst.ini:/etc/odbcinst.ini:ro
      - ./php:/usr/local/etc
      - ./msmtp/msmtprc:/etc/msmtprc:ro
    environment:
      - APACHE_RUN_USER=www-data
      - APACHE_RUN_GROUP=www-data
      - APACHE_PID_FILE=/run/apache2.pid
    networks:
      - web
    labels: &apache_labels_default
      - "traefik.enable=true"
      - "traefik.http.routers.robot-dka-teralab-com.rule=Host(`robot.dka.teralab.com`)"
      - "traefik.http.routers.robot-dka-teralab-com.tls=true"
      - "traefik.http.services.robot-dka-teralab-com.loadbalancer.server.port=80"

networks:
  web:
    external: true

I use windows 10 with UBUNTU WSL.

Cal you tell us about the change? 502 bad gateway means you connect to a proxy server which cannot connect to the server behind it. In your case it could be a load balancer in front of Apache HTTPD or Apache HTTPD itself trying to connect to PHP FPM.

Thank you for your help, I really appreciate that.

I would love to copy paste the inspected images into here, but they contain sensitive data that I cannot share, so I will try to describe the differences between Image1 (the old image) and Image2 (the new one).

THESE ARE 4 MAIN DIFFERENCES BETWEEN THE OLD IMAGE AND THE NEW ONE:

1] Image2 contains these 3 lines which are not found in Image1:

3	/bin/sh -c #(nop) ENV no_proxy=teralab.com	0 Bytes
4	/bin/sh -c #(nop) ENV https_proxy=http://proxy.teralab.com:1234	0 Bytes
5	/bin/sh -c #(nop) ENV http_proxy=http://proxy.teralab.com:1234	0 Bytes

2] PHP version changed from 7.4.8 (in Image1) to 8.0.8 (in Image2):

23	/bin/sh -c #(nop) ENV PHP_VERSION=8.0.8	0 Bytes

3] HTTPD_VERSION change from 2.4.43 to 2.4.46 (Image2):

46	/bin/sh -c #(nop) ENV HTTPD_VERSION=2.4.46	0 Bytes

4] Also, some 3rd party apps were installed via composer with this new Image2 (composer itself wasn’t located in the old Image1), but I do not think this reason could have caused 502

Does Apache HTTPD uses mod_php or PHP FPM in the same container? Do you have any other service which should be available through Apache HTTPD?

Check the HTTPD error logs. I think it should contain what HTTPD could not access. Maybe no_proxy configured incorrectly.

1 Like