On 2 Sep 2022, at 4:57 am, Juan Khawly <juan...@gmail.com> wrote:
Hello,I've been running into this problem for a while.CONTEXTI have an application developed in python (3.10), django 4.0.3, using mod_wsgi and apache. The application is in a DEV environment and hosted in AWS EC2. Currently, it does not receive traffic at all.Installation of Mod WSGIapt-get install -y apache2-devSetup out of the VENVmod_wsgi-express install-moduleediting: /etc/apache2/mods-available/wsgi.loadLoadModule wsgi_module "/usr/lib/apache2/modules/mod_wsgi-py310.cpython-310-x86_64-linux-gnu.so"
WSGIPythonHome "/data/home/user/environment/venv"Module Enableda2enmod wsgiPROBLEMThe application works perfect most of the time. Couple of times a week, without traffic the apache server goes down into 503. Usually it is preceded by a random request but it does not always happen that way. I am assuming that is Slow DDOS but I want to make sure it is not miss configuration of the WSGI.access.log example
<access.PNG>error.log exampleI masked the internal routesThis is one of the errors:[Thu Sep 01 04:22:21.520772 2022] [wsgi:error] [pid 3267:tid 140518453380864] [client 118.126.82.157:37722] Timeout when reading response headers from daemon process 'XXXXX': /XXX/XXXX/XXXXX/XXXXX/XXXXXX/wsgi.pyAnother type of error:[Thu Sep 01 04:22:21.520772 2022] [wsgi:error] [pid 3267:tid 140518453380864] [client 118.126.82.157:37722] Timeout when reading response headers from daemon process 'XXXXXXX': /XXX/XXXX/XXXXX/XXXXXX/XXXXXXX/wsgi.pySOLUTIONIf I restart the server, all works again until next failure.I've enabled the following modules, in case it is SlowDDOSmodreqtimeoutlibapache2-mod-qoslibapache2-mod-security2.Any recommendation?Thanks,Juan Khawly
--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/3cc5285a-9943-4143-9b7f-5fa24e681c70n%40googlegroups.com.
<access.PNG>
To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/d837af27-86cb-4ef6-877a-40f52418a8d0n%40googlegroups.com.
On 7 Sep 2022, at 11:43 pm, Juan Khawly <juan...@gmail.com> wrote:Graham,
Going to make that change, monitor and keep this chat updated with the result.2 Questions:1) The option request-timeout = 60 is included inside the virtual host along with the rest of the Daemon code right ?
2) Under no traffic, do you have any idea of why this problem could happen? As I explained, it is usually, but not always, preceded by couple of GET Request from a random IP (bot requests) to random urls. My assumption was Slow DDOS and this is why I enabled modreqtimeout, mod security and mod qos. But at this point I'm clueless of how to diagnose.
To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/db12a0a4-0acf-4c90-b8a8-4b749f493f7an%40googlegroups.com.
On 10 Sep 2022, at 2:41 am, Juan Khawly <juan...@gmail.com> wrote:Graham,After adding the timeout, as you said, the server auto recovers from the problem.After mod_wsgi is logging info level. My error log now gives traces of where the problem is. I'm attaching my error.log from today (sep 09), any ideas?Thanks for the support.Juan Khawly
To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/4c08f3cf-54f6-43a3-809d-a463723c274cn%40googlegroups.com.
<error.log>
To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/a69d70f4-faac-4515-b991-90590efd7b95n%40googlegroups.com.
On 11 Sep 2022, at 2:25 am, Juan Khawly <juan...@gmail.com> wrote:
Graham,
If I take the the get_wsgi_application() out of the function, my site throws error an internal error. Looking inside the logs, it all comes down that my app is not receiving the value of VAR1 or VAR2 that are further used in my settings.py to setup the environment. VAR1 and VAR2 are environment variables that help me recognize if I am in LOCAL, DEV or PROD.Also, I honestly didn't understand this comment if you can help me see more clearly. "Be aware that what you are doing is not technically safe because environment variables are global and so if different URLs ended up in different values for the variables, then a different request could change it before you got to use it."
My goal is having environmental variables inside my virtual host and pass them to the Django app. I tried this using the environment variables files that Linux uses but I was never successful to pass them to my Django app.
To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/33b4cf84-410f-48d8-a062-4d1ef5e92a50n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/e77b2844-6948-457b-8a13-65ef7698c377n%40googlegroups.com.