nginx.conf:
user nginx;
worker_processes auto;
pid /tmp/nginx.pid;
# turn off daemon mode to be watched by supervisord
daemon off;
pcre_jit on;
error_log /var/log/nginx/error.log warn;
# events block defines the parameters that affect connection processing.
events {
# Define the maximum number of simultaneous connections that can be opened by a worker process
worker_connections 1024;
}
# SSL configuration
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.example.nl example.nl;
ssl_certificate /etc/letsencrypt/live/example.nl/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.nl/privkey.pem;
# Improve HTTPS performance with session resumption
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
location / {
try_files $uri @yourapplication;
}
location @yourapplication {
include uwsgi_params;
uwsgi_pass unix:///tmp/uwsgi.sock;
}
}
uwsgi.ini
[uwsgi]
module = src.main
callable = app
uid = nginx
gid = nginx
socket = /tmp/uwsgi.sock
chown-socket = nginx:nginx
chmod-socket = 664
cheaper = 1
processes = %(%k + 1)
Dockerfile:
FROM python:3.9
RUN apt-get update
RUN apt-get install -y --no-install-recommends
libatlas-base-dev gfortran nginx supervisor
RUN pip3 install uwsgi
COPY ./requirements.txt /project/requirements.txt
RUN pip3 install -r /project/requirements.txt
RUN useradd --no-create-home nginx
RUN rm /etc/nginx/sites-enabled/default
RUN rm -r /root/.cache
COPY server-conf/nginx.conf /etc/nginx/
# COPY server-conf/flask-site-nginx.conf /etc/nginx/conf.d/
COPY server-conf/uwsgi.ini /etc/uwsgi/
COPY server-conf/supervisord.conf /etc/supervisor/
COPY src /project/src
WORKDIR /project
ENV PYTHONPATH "${PYTHONPATH}:/project/src"
CMD ["/usr/bin/supervisord"]
docker-compose.yml
version: '3'
services:
app:
build: .
ports:
- "5000:80"
volumes:
- .:/project
Those are my files which should run my application on an HTTPS connection. I have an index.html file which I added manually and the rules I added manually which does work. But when I try to run my webapp on these settings it doesn’t work. When I go to my url with the port it says SSL PROTOCOL ERROR. Am I missing out on something?
I’ve been trying to get this work for the past 2-3 days. The HTTP did work before but I changed my nginx.conf to try and make it work with HTTPS but no success so far. I would appreciate any help!