r/flask • u/Dangerous-Pressure49 • 14h ago
Ask r/Flask How do i set up a SSL certificate on flask app with mod_wsgi inside a docker containter
I signed up on cloudflare and got a free SSL certificate and i have a .pem file and a .key file and here is the dockerfile i used for my image
# Start with a base Python image
FROM python:3.11
# Install necessary system packages
RUN apt-get update && \
apt-get install -y \
apache2 \
apache2-dev \
libapache2-mod-wsgi-py3 \
locales \
&& rm -rf /var/lib/apt/lists/*
# Generate locale and set locale environment variables
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
locale-gen && \
update-locale LANG=en_US.UTF-8
# Create a non-root user and group
RUN groupadd -r mostafa && useradd -r -g mostafa mostafa
# Create a directory for your application
RUN mkdir /application && chown mostafa:mostafa /application
# Set the working directory
WORKDIR /application
# Copy the entire application source code into the container
COPY --chown=mostafa:mostafa . .
# Install Python dependencies
RUN pip install -r requirements.txt
# Expose the higher port
EXPOSE 80
# Switch to the non-root user
USER mostafa
# Command to run the server on port
CMD ["mod_wsgi-express", "start-server", "/application/wsgi.py", "--port", "80", "--processes", "1"]
How can i modify this dockerfile to use https
```