Ivole32
Ivole32

Reputation: 1

How to fix apache2 crashing without any error message

I'm trying to use Apache2 as reverse proxy with my Gunicorn/Python Flask app in a docker container but apache2 crashes without any error message. I tryed asking ChatGPT
and researched over the internet but I don't found a solution...

Dockerfile:

FROM python:3.9-slim

WORKDIR /app

COPY . /app

RUN if [ -f requirements.txt ]; then \
        pip install --no-cache-dir -r requirements.txt; \
    else \
        pip freeze > requirements.txt && pip install --no-cache-dir -r requirements.txt; \
    fi

EXPOSE 8000

ENV FLASK_APP=app.py

CMD ["gunicorn", "-b", "0.0.0.0:8000", "app:app"]

docker-compose.yml:

services:
  web:
    build: .
    expose:
      - "8000"
    environment:
      - FLASK_ENV=production

  apache:
    image: httpd:latest
    ports:
      - "443:443"
    volumes:
      - ./apache.conf:/usr/local/apache2/conf/httpd.conf
      - ./cert.pem:/usr/local/apache2/certificates/cert.pem
      - ./key.pem:/usr/local/apache2/certificates/key.pem
    depends_on:
      - web

  memcached:
    image: memcached:latest
    container_name: memcached
    ports:
      - "11211:11211"
    restart: always

apache.conf:

LoadModule mpm_event_module modules/mod_mpm_event.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule headers_module modules/mod_headers.so
LoadModule log_config_module modules/mod_log_config.so

ServerAdmin webmaster@localhost
Listen 443
ServerName localhost

<VirtualHost *:443>

    SSLEngine on
    SSLCertificateFile /usr/local/apache2/certificates/cert.pem
    SSLCertificateKeyFile /usr/local/apache2/certificates/key.pem

    ProxyPass / http://web:8000/
    ProxyPassReverse / http://web:8000/

    Header always set X-Frame-Options "SAMEORIGIN"
    Header always set X-XSS-Protection "1; mode=block"
    Header always set X-Content-Type-Options "nosniff"

    LogLevel warn
    ErrorLog /usr/local/apache2/logs/error_log
    CustomLog /usr/local/apache2/logs/access_log combined
</VirtualHost>

The apache log is only apache-1 exited with code 1

Note: If you see any wrong set ports, please tell me.

Upvotes: 0

Views: 25

Answers (0)

Related Questions