diff --git a/Dockerfile b/Dockerfile index 0f1c93a..ee3ffe3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,8 +9,6 @@ RUN pip install --no-cache-dir -r requirements.txt EXPOSE 5000 -ENV WORKERS 2 ENV IP_API false -ENV FLASK_ENV production -ENTRYPOINT exec gunicorn -w $WORKERS -b 0.0.0.0:5000 ipget:app +CMD ["gunicorn", "-c", "gunicorn.py", "ipget:app"] diff --git a/docker-compose.yaml b/docker-compose.yaml index c14fd94..b5ddd0a 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,12 +2,14 @@ version: '3.8' services: ipget: - image: prestigen/ipget:0.0.1 + image: prestigen/ipget:0.0.2 hostname: ipget environment: - - WORKERS=4 + - GUNICORN_SERVER= # default: ipget + - GUNICORN_BIND= # default: "0.0.0.0:5000" + - GUNICORN_WORKERS= # default: cores * 2 + 1 + - GUNICORN_THREADS= # default: 1 - IP_API=false - - FLASK_ENV=production restart: always nginx: diff --git a/ipget/VERSION b/ipget/VERSION index 8acdd82..4e379d2 100644 --- a/ipget/VERSION +++ b/ipget/VERSION @@ -1 +1 @@ -0.0.1 +0.0.2 diff --git a/ipget/gunicorn.py b/ipget/gunicorn.py new file mode 100644 index 0000000..6d7e7a1 --- /dev/null +++ b/ipget/gunicorn.py @@ -0,0 +1,9 @@ +import gunicorn +import os +import multiprocessing + +gunicorn.SERVER = os.getenv("GUNICORN_SERVER") or "ipget" +bind = os.getenv("GUNICORN_BIND") or "0.0.0.0:5000" +workers = os.getenv("GUNICORN_WORKERS") or multiprocessing.cpu_count() * 2 + 1 +threads = os.getenv("GUNICORN_THREADS") or 1 +disable_redirect_access_to_syslog = True diff --git a/resources/nginx.conf b/resources/nginx.conf index f550028..93b8242 100644 --- a/resources/nginx.conf +++ b/resources/nginx.conf @@ -25,6 +25,7 @@ http { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; + proxy_pass_header Server; } } diff --git a/run.sh b/run.sh index 5e3a9ad..5a74af1 100755 --- a/run.sh +++ b/run.sh @@ -1,3 +1,3 @@ #!/bin/sh -gunicorn -w ${WORKERS:-2} -b 0.0.0.0:5000 ipget.ipget:app +gunicorn -c ipget/gunicorn.py ipget.ipget:app