Bugfix: rest path (URI) was always "/" even if a path is provided#155
Bugfix: rest path (URI) was always "/" even if a path is provided#155f-froehlich wants to merge 1 commit intoborgbackup:masterfrom
Conversation
|
The purpose of The path isn't used for that, so it could be "/" (this is what the code expects) or empty (that would be another option). Later, when using that backend (== calling the backend api methods), URLs will be constructed by joining the base_url with the storage item path (argument of api calls). |
|
Then there must be something wrong elsewhere. If I call:
There is a request made The provided change fixed this issue. |
|
First setup the REST server, you give the path to the store there: Then use: |
|
Yes I know that but the route Another example would be use different backends on one webserver so the repository could be at |
|
Well, the REST server as it is now only deals with forwarding the requests to 1 backend and it gives the PATH it gets in a request directly to the backend, so there must not be any path prefix. |
|
Yes but you can spin up 200 instances of the borgstore server on one host on a different port and use a reverse proxy to use the right one. However this wont work if a repo-create (and other requests) always uses path /. So I need 200 different vhost configs with tls setup (and in my case also 200 IPv6 ips) in order to get it running. This is overkill for a simple regex change. The current behavior doesn't chang so if I already use a borgstore instance on / it will be running on / even with this change |
|
OK, so, would your reverse proxy setup remove the base path from the request it does to the borgstore REST server, so that it only sees the correct path for the store, without the base path? |
|
Guess we need better docs for this. The REST server setup could be split off in a separate SERVER.rst that explains a typical (e.g. nginx) reverse proxy setup with the borgstore REST server. |
|
This would be one option to do so. However I'm trying to get it working with a custom REST backend implementation witch is capable of handling multiple repositories while only using a single django rest application |
|
Ah, ok, so you are not using the borgstore rest server. How about the trailing slash? In your PR, there now must be a trailing slash when using the root path, but it is not required when using a path below that. Guess it should be either always be optional (and normalized by the code) or it should be always required? |
|
In my tests if I don't add the / at the end of the url it uses the PosixFS backend instead. This is also the case without my changes |
|
Yes, that is because borg requires the trailing slash for the rest backend. Also, the posixfs regex catches a lot of stuff because filenames on posix can be almost anything. OK, so for consistency: always require the trailing slash here also? OR: not require it (and also not require it in borg) |
|
You only need a / after the domain/port so |
|
my question refers to the desired "how it should be" state, not necessarily to the current state. |
|
Note: making the path group optional will result in path == None if no path is given. Is it required to be optional? |
|
If you're having a decision I can change the regex if needed. |
|
How about this? Also, some tests whether the URLs are built correctly would be nice (no path, /, /sub, /sub/). |
See discussion in PR borgbackup#155. The backend code will work ok even with an empty path or without a trailing slash. Note: the REST server currently does not support sub-paths, but only serves one backend / store at the root path. There is now a contrib/server/nginx-systemd/ subdirectory with a reverse proxy setup example that can support multiple stores at different sub-paths.
|
Superceded by #156 - I needed it there to get the tests for the CI nginx reverse proxy setup with sub-path dispatching working. @f-froehlich Thanks for bringing this up, this was an important change. It looks like nginx can also do that sub-path -> / transformation, so that one borgstore server process still only has to deal with 1 store and item paths directly below the root path. I found that the code can happily live without any trailing slash, because it strips and re-adds it anyway when constructing URLs. So making the path optional was a good idea, so users stumble less over "bad" URLs. It just needed that |
See discussion in PR borgbackup#155 and thanks to @f-froehlich for bringing this up! The backend code will work ok even with an empty path or without a trailing slash. Note: the REST server currently does not support sub-paths, but only serves one backend / store at the root path. There is now a contrib/server/nginx-systemd/ subdirectory with a reverse proxy setup example that can support multiple stores at different sub-paths.
See discussion in PR borgbackup#155 and thanks to @f-froehlich for bringing this up! The backend code will work ok even with an empty path or without a trailing slash. Note: the REST server currently does not support sub-paths, but only serves one backend / store at the root path. There is now a contrib/server/nginx-systemd/ subdirectory with a reverse proxy setup example that can support multiple stores at different sub-paths.
No description provided.