-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update nginx.rst -- Reworked the Nginx configs #2197
Conversation
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>
Force-pushed to overwrite commit and make some minor spelling/formatting fixes |
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. |
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. |
- 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>
@josh4trunks I've made some changes to address your comments, see commit message for details. |
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. |
No rush! I can only imagine how cumbersome moving house is in the middle of a pandemic 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NextCloud => Nextcloud
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. |
@kesselb, done 😉 |
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.
Discussed here > #2197 (comment)
Note is no longer relevant
@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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accidental review, please dismiss.
@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 |
your rewrite rule fix my issue with the ldap app. |
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. |
cross-referencing rainloop which suffers from the same issue as LDAP-config here |
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? |
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. |
@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 |
Thanks to both of you. I managed to get it working! |
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? 😁 |
PR submit at #7141. |
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
.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.