Eu configurei o Nginx com gunciron e django. Tudo parece funcionar bem, pelo menos era o que eu acreditava. No entanto, quando eu verifico o diretório .gunicorn-logs conforme especificado para ser criado no docker e especifiquei o myscipt.sh abaixo, ele mostra 2 arquivos:
access.log com todo o acesso ao servidor gunciron e
error.log que deveria estar vazio mostra 1 kb de arquivo.
Upon inspection, I get this inside --->
Gunicorn error.log file --->
[2024-12-05 04:36:15 +0000] [85] [INFO] Starting gunicorn 23.0.0
[2024-12-05 04:36:15 +0000] [85] [INFO] Listening at: http://0.0.0.0:8585 (85)
[2024-12-05 04:36:15 +0000] [85] [INFO] Using worker: gthread
[2024-12-05 04:36:15 +0000] [88] [INFO] Booting worker with pid: 88
[2024-12-05 04:36:15 +0000] [89] [INFO] Booting worker with pid: 89
[2024-12-05 04:36:15 +0000] [90] [INFO] Booting worker with pid: 90
[2024-12-05 04:36:15 +0000] [91] [INFO] Booting worker with pid: 91
Gunciron access.log file --->
49.xxx.xxx.xx - - [05/Dec/2024:10:06:26 +0530] "GET /admin/login/?next=/admin/ HTTP/1.1" 200 4158 "-" "PostmanRuntime/7.43.0"
127.0.0.1 - - [05/Dec/2024:10:06:35 +0530] "GET /static/admin/ HTTP/1.1" 302 0 "-" "PostmanRuntime/7.43.0"
127.0.0.1 - - [05/Dec/2024:10:06:36 +0530] "GET /admin/login/?next=/static/admin/ HTTP/1.1" 200 4172 "http://34.xxx.xxx.xx:75/static/admin/" "PostmanRuntime/7.43.0"
127.0.0.1 - - [05/Dec/2024:10:06:42 +0530] "GET /static/admin/ HTTP/1.1" 302 0 "-" "PostmanRuntime/7.43.0"
127.0.0.1 - - [05/Dec/2024:10:06:42 +0530] "GET /admin/login/?next=/static/admin/ HTTP/1.1" 200 4172 "http://34.xxx.xxx.xx:75/static/admin/" "PostmanRuntime/7.43.0"
Os arquivos de log do nginx têm apenas o access.log preenchido e o error.log está vazio.
Nginx access.log file ---->
49.xxx.xxx.xx - - [05/Dec/2024:04:36:35 +0000] "GET /static/admin/ HTTP/1.1" 302 0 "-" "PostmanRuntime/7.43.0" "-"
49.xxx.xxx.xx - - [05/Dec/2024:04:36:36 +0000] "GET /admin/login/?next=/static/admin/ HTTP/1.1" 200 1522 "http://34.xxx.xxx.xx:75/static/admin/" "PostmanRuntime/7.43.0" "-"
49.xxx.xxx.xx - - [05/Dec/2024:04:36:42 +0000] "GET /static/admin/ HTTP/1.1" 302 0 "-" "PostmanRuntime/7.43.0" "-"
49.xxx.xxx.xx - - [05/Dec/2024:04:36:42 +0000] "GET /admin/login/?next=/static/admin/ HTTP/1.1" 200 1526 "http://34.xxx.xxx.xx:75/static/admin/" "PostmanRuntime/7.43.0" "-"
Veja como defini as linhas relacionadas ao servidor gunicorn dentro do dockerFile.
RUN mkdir -p .gunicorn-logs
RUN touch /opt/.gunicorn-logs/error.log
RUN touch /opt/.gunicorn-logs/access.log
RUN chmod +x /opt/.gunicorn-logs/
cmd myscipt.sh
O myscript.sh onde nginx e gunciron são invocados --->
#!/bin/sh
nginx -g 'daemon off;' &
gunicorn mydjangoapi.wsgi:application --config=gunicorn_config_api-1.py
Finalmente, gunicorn_config_api-1.py parte da pasta raiz --->
bind = "0.0.0.0:8585"
loglevel = "INFO"
workers = "4"
threads="10"
reload = True
errorlog = "/opt/.gunicorn-logs/error.log"
accesslog = "/opt/.gunicorn-logs/access.log"