In Brief
I have a WSGI script mounted at /app
. If I request /app/resource
, I get a correct response. But I also get an entry in my error log as if I had requested /resource
. What could cause this?
In Detail
I have a Flask application deployed with Apache 2.4 + mod_wsgi on AWS EC2:
- The application lives at
/my/app/path
- The
app.wsgi
file lives at/var/www/wsgi
and points to/my/app/path
- The Apache config for the
www.website.com
vhost points to the WSGI script:
WSGIScriptAlias /app /var/www/wsgi/app.wsgi
When I GET www.website.com/app/some_resource/...
, I receive the expected response for that resource with code 200
.
However, when I check the Apache error logs, I find loads of entries for denied requests, e.g.:
[authz_core:error] [pid XXXXX] [client XXXXX] XXXXX: client denied by server configuration: /var/www/html/some_resource
The logged errors correspond 1-to-1 with requests that, as stated, come back 200
.
Now, /var/www/html
is the default DocumentRoot, but the request is sent to the /app
location, and is correctly passed-to and handled-by the WSGI application via the alias directive.
And so: Why might I find these entries in my error logs, in which the /app
path is removed, and the resource path appended directly (and correctly denied) on the root?
Follow-Up
To respond to Graham's suggestions in the comments:
- There are no Apache rewrite rules defined.
- Apache is not setup with MultiViews
- These are JSON resources; the errors are not the result of sub-requests from a loaded document.
- Issue persists without symlinks.
Update
A colleague tells me he has encountered the same issue on AWS EC2 instances.
favicon.ico
etc and depending on permissions that can fail. – Boonysome_resource
in the example GET request, and a corresponding line will appear in the error log. – Tancred/
before the ellipsis in the example request does not affect the entry in the error_log. – Tancred/app
"), and passing the remainder (aka "/some_resource/...
") to the WSGI application. In which case, why does the error_log contain this entry in which the "remainder" is simply appended to the DocumentRoot, with apparently no effect on the handling of the request? – Tancredcurl
from the command line to access the URL, do you still see multiple requests and the failures? If you see them withcurl
then it is something strange about your Apache setup. If you don't see them fromcurl
but do from browser, suggestive of sub requests from main resources. BTW, if by points to you mean a symlink, they can sometimes cause issues with Apache resource matching. Can you not use the symlink. – Boony