backends-nginx: Add support for Nginx versions older than 1.5.9.#64
backends-nginx: Add support for Nginx versions older than 1.5.9.#64adnrs96 wants to merge 1 commit intojohnsensible:masterfrom
Conversation
|
Wouldn't it be simpler to have a configuration parameter for this ? Trying to get nginx version with subprocess when you might not be able to run it or not be on the same machine at all (think docker, etc) seems like over-complication. |
|
Indeed it would be simpler @EvaSDK . Having a configuration parameter for this was the second thing in my mind. Didn't thought of Docker use case otherwise it would have become the first. Workflow for that would be something like this:
If community feels good with this change I can update the PR. Just leave me a comment regarding this. |
4488e52 to
d69f33f
Compare
In this commit we are adding support for Nginx version older than 1.5.9. This is achieved through conditionally quoting the URL's in X-Accel-Redirect headers according to compatibility with Nginx. Since newer versions of Nginx expect URL's in X-Accel-Redirect to be quoted unlike the versions older that Nginx 1.5.9. From this commit onwards we start to expect a 'NGINX_VERSION' config setting to be setup in the django settings in order to facilitate decision making regarding quoting URL's. If such a setting is not found we just assume Nginx version to be greater then 1.5.9 and make decision accordingly and then cache the decision by making use of a decorator. Using this result we decide whether the outgoing URL should be quoted or not. Fixes: johnsensible#56, johnsensible#58. Closes johnsensible#45.
|
I figured it would be better to have a updated commit for community to review than just a workflow, so I have updated the commit. Also added instructions in Readme regarding the same. |
|
Looks much better to me. |
In this PR we are adding support for Nginx version older than 1.5.9. This is achieved through conditionally quoting the URL's in X-Accel-Redirect headers according to compatibility with Nginx. Since newer versions of Nginx expect URL's in X-Accel-Redirect to be quoted unlike the versions older that Nginx 1.5.9. In this commit we start to check the Nginx version using 'nginx -v' and then caching the result be making use of a decorator. Using this result we decide whether the outgoing URL should be quoted or not.
This will not break Unicode support as revealed from my investigation. I tried out Django-sendfile 0.3.11 with Nginx 1.4.6. This leads to 404's which are resolved when we stop quoting the URL's. It might be worthwhile mentioning after making such a change filenames such as
á.txtandБ.txtwere still functional and correctly recognised.Fixes: #56, #58. Closes #45.