Uh oh!
There was an error while loading. Please reload this page.
Update nginx.rst -- Reworked the Nginx configs - #2197
Conversation
MorrisJobke
commented
Jul 11, 2020
cc @josh4trunks |
After inspecting the Nginx configs currently seen at [ https://docs.nextcloud.com/server/19/admin_manual/installation/nginx.html ], I have notice that they are very redundant in some areas, and handle specific paths in special ways which are not needed, and which run the risk of needing to become more specific down the road if NextCloud adds new features, as well as not handling all static filetypes. I have reworked the configs from scratch by directly adapting the `.htaccess` files, and this is the result. Comments are included in the file to give rationale/explanation for why things are written in this new way, and if the maintainers decide to accept this pull request, I will leave it up to them to decide whether to include these expository comments upstream. Signed-off-by: Jivan Pal <jivan.pal@gmail.com>
jivanpal
commented
Jul 12, 2020
Force-pushed to overwrite commit and make some minor spelling/formatting fixes |
josh4trunks
commented
Jul 12, 2020
Thanks for looking at this @jivanpal! If possibly, please dont force overwrite the commit, I had reviewed the previous version of the file and now I can't see what was changed. Next time, just push another commit on top so we get the whole messy history, lol. No worries we all have typos and need to change things. |
josh4trunks
commented
Jul 12, 2020
I agree with you that we should strive to match the .htaccess file as well as we can without sacrificing security/performance; that way we can more easily incorporate changes added to Nextcloud's codebase. I'll try adding my comments into the file, so its easier to know what I'm asking and you can respond when you have time. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Removed `index.htm` from `index` directive - Rewrote `DavClnt` user agent handler using `location =` and `return`, rather than `rewrite` - Removed block which prevents access to hidden files; incorporated rule to prevent access to root-level hidden folders into existing regex rule, as in `.htaccess` - Removed `$uri/` from `try_files` directives for static files Signed-off-by: Jivan Pal <jivan.pal@gmail.com>
jivanpal
commented
Jul 12, 2020
@josh4trunks I've made some changes to address your comments, see commit message for details. |
Uh oh!
There was an error while loading. Please reload this page.
josh4trunks
commented
Jul 17, 2020
If you don't mind giving me a few more day, I still want to test and propose any changes I think need to be made. |
jivanpal
commented
Jul 17, 2020
No rush! I can only imagine how cumbersome moving house is in the middle of a pandemic 😅 |
josh4trunks
commented
Jul 27, 2020
Haven't forgot about this, still on my list, just recovering from moving with a baby and dog, lol. I got my test server plugged in, and should have some time to look at this tomorrow night and will comment. |
jivanpal
commented
Jul 27, 2020
@kesselb, done 😉 |
Uh oh!
There was an error while loading. Please reload this page.
I think we mostly agree on these, grouping them for easy merging. Creating a new branch is giving me an error for some reason, so I will commit directly. If necessary we can always revert.
You probably are correct on NGINX optimizing groups with unused captures into non-capturing groups, but unless we know for sure/see documentation I think it is best we are explicit.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Discussed here > #2197 (comment)
Uh oh!
There was an error while loading. Please reload this page.
Note is no longer relevant
josh4trunks
commented
Aug 6, 2020
@jivanpal, I plan on testing an Apache configuration in the next few days and after that can resolve this comment #2197 (comment). Do you mind responding to my 4 additional comments posted today? I think 3 of them can be settled very easily. This comment may take a little more back and forth to reach agreement since it affects more lines, but I'll do my best to respond quickly. Thank you |
- Changed `try_files` for `/.well-known` to allow URIs that we don't handle and not pass them to our front-end controller - Changed rule to match `/nextcloud/*` from regex rule to equivalent prefix rule
jivanpal
left a comment
There was a problem hiding this comment.
Accidental review, please dismiss.
Uh oh!
There was an error while loading. Please reload this page.
@josh4trunks, you said:
Regarding #5472, if the behaviour in Apache is to not cache, then I'm guessing that it is due to this app using its own Regarding the specific issue with |
schleyk
commented
Dec 21, 2020
your rewrite rule fix my issue with the ldap app. |
jolly-jump
commented
Jan 16, 2021
I used this in my NC 20 which was upgraded from way below and then migrated to a new server where I initially put in the nginx-config that was given in the docs (two days ago), which did not work for LDAP AND did not work for the rainloop addon! Thanks for the fix. I'll try and tell the rainloop people as well. |
jolly-jump
commented
Jan 16, 2021
cross-referencing rainloop which suffers from the same issue as LDAP-config here |
etique57
commented
Apr 9, 2021
Hello @corsac-s I'm in the same configuration as you (/nextcloud/ path, reverse-proxy in front) and observes the same effect of the fix as you (general 404). Did you find a solution? |
corsac-s
commented
Apr 10, 2021
I kind of lost track of what I did and didn't do. In the end, on my Apache reverse proxy, I use (using Unix sockets but I guess it should be the same with network): Then on the nginx part, I use: Hope that helps. |
jivanpal
commented
Apr 10, 2021
@etique57@corsac-s — The solution should be to change the rewrite rule to account for the subpath/subdir you're using, e.g. if your site is at I am not sure whether this warrants a PR to modify the default Nginx config, given that the behaviour of the LDAP app relies on modifying Apache |
etique57
commented
Apr 10, 2021
Thanks to both of you. I managed to get it working! |
ChristophWurst
commented
Sep 20, 2021
Thanks a lot @jlehtoranta. I could verify that the current config doesn't work with the LDAP wizard and that your config revives the legacy routes. Could you open this as pull request? Otherwise I will do so if nobody sees any other issues with this config. I suppose those who used this trick still use the config in production, right? 😁 |
ChristophWurst
commented
Sep 24, 2021
PR submit at #7141. |
KoMa1012
commented
Mar 5, 2022
this does not work for me, nextcloud 23 I get: |
After inspecting the Nginx configs currently seen at [ https://docs.nextcloud.com/server/19/admin_manual/installation/nginx.html ], I have notice that they are very redundant in some areas, and handle specific paths in special ways which are not needed, and which run the risk of needing to become more specific down the road if NextCloud adds new features, as well as not handling all static filetypes. I have reworked the configs from scratch by directly adapting the
.htaccessfiles, and this is the result. Comments are included in the file to give rationale/explanation for why things are written in this new way, and if the maintainers decide to accept this pull request, I will leave it up to them to decide whether to include these expository comments upstream.