Skip to content
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

[Feature Request] Dynamic FILE_SERVER_ROOT setting based on current hostname #3398

Closed
YanzheL opened this issue Apr 30, 2019 · 2 comments
Closed

Comments

@YanzheL
Copy link

YanzheL commented Apr 30, 2019

Deployment environment

The seafile server and seahub server are hosted at the same host in a private network, for example:

  • Seafile server listen on 10.0.0.1:8082
  • Seahub server listen on 10.0.0.1:8000
  • A reverse proxy (e.g Nginx) listen on 10.0.0.1:80, this is the main entry point for user.

Current use case

If I use
SERVICE_URL = http://10.0.0.1 and FILE_SERVER_ROOT = http://10.0.0.1/seafhttp

then users on the private network can visit the Seafile service by http://10.0.0.1 and do upload/download without any problem.

Desired use case

Now I want to public the Seafile service to public network.

I have another server on public network with a domain abc.example.com, and I successfully set up a reverse proxy that redirecting local port 10.0.0.1:80 to abc.example.com:80.

So I use this setting:
SERVICE_URL = http://abc.example.com and FILE_SERVER_ROOT = http://abc.example.com/seafhttp

Now users on public network can reach the Seafile service by http://abc.example.com/seafhttp and do upload/download without any problem.

However, the FILE_SERVER_ROOT URL variable is used in frontend js. It means that the actual upload/download is requested against this URL by user's browser.

This leads to a problem that users on private network will do the upload/download request through this public address http://abc.example.com/seafhttp instead of a private address http://10.0.0.1/seafhttp, which is not a desired behavior. It's not necessary for private network users to request that public URL because requests in private network are generally much more faster than going through a public reverse proxy.

Two possible solutions

  1. Seahub as a proxy.

    It's not necessary to expose the actual file server URL to users. Seahub server can act as a proxy that retrieves files from backend Seafile server and serve this file to users directly. So users will only "see" one hostname during the whole procedure.

    This solution requires Seahub to be a proxy, which may lead to performance issues and API changes, but the idea is straightforward.

  2. Dynamic file server URL.

    If users visit the service by http://abc.example.com, then the file server URL used in frontend is http://abc.example.com/seafhttp.

    If users visit the service by http://10.0.0.1, then the file server URL used in frontend is http://10.0.0.1/seafhttp.

    This is easy to implement in frontend js.

    var fileServerRoot = window.location.hostname + FILE_SERVER_PATH;

    The FILE_SERVER_PATH variable is configurable through admin manage page. Its value is /seafhttp in this case.

    This solution requires seafile server and seahub server are reachable under the same hostname, which is a very common and practical use case.

    This is what I recommend and the benefit of this solution is really impressive. So I suggest you can provide an option in admin settings to enable this feature. Thanks.

@YanzheL
Copy link
Author

YanzheL commented Jun 29, 2019

I figured it out, just set the FILE_SERVER_ROOT with /seafhttp. The important part is to omit the host prefix.

@YanzheL YanzheL closed this as completed Jun 29, 2019
@HanTango
Copy link

非常感谢。
Thanks a lot.

DanielEgbers added a commit to DanielEgbers/rclone that referenced this issue Jan 14, 2024
…e url

a seafile server can be configured to use a relative url as FILE_SERVER_ROOT in order to support more than one hostname/ip.
(see haiwen/seahub#3398 (comment))
the previous backend implementation always expected an absolute download/upload url, resulting in a "unsupported protocol scheme" error.
with this commit it supports both absolute and relative.
DanielEgbers added a commit to DanielEgbers/rclone that referenced this issue Jan 14, 2024
…e url

a seafile server can be configured to use a relative url as FILE_SERVER_ROOT in order to support more than one hostname/ip.
(see haiwen/seahub#3398 (comment))
the previous backend implementation always expected an absolute download/upload url, resulting in an "unsupported protocol scheme" error.
with this commit it supports both absolute and relative.
DanielEgbers added a commit to DanielEgbers/rclone that referenced this issue Jan 14, 2024
a seafile server can be configured to use a relative url as FILE_SERVER_ROOT in order to support more than one hostname/ip.
(see haiwen/seahub#3398 (comment))
the previous backend implementation always expected an absolute download/upload url, resulting in an "unsupported protocol scheme" error.
with this commit it supports both absolute and relative.
ncw pushed a commit to rclone/rclone that referenced this issue Feb 5, 2024
A seafile server can be configured to use a relative URL as
FILE_SERVER_ROOT in order to support more than one hostname/ip. (see
haiwen/seahub#3398 (comment) )

The previous backend implementation always expected an absolute
download/upload URL, resulting in an "unsupported protocol scheme"
error.

With this commit it supports both absolute and relative.
Fornax96 pushed a commit to Fornaxian/rclone that referenced this issue Jul 30, 2024
A seafile server can be configured to use a relative URL as
FILE_SERVER_ROOT in order to support more than one hostname/ip. (see
haiwen/seahub#3398 (comment) )

The previous backend implementation always expected an absolute
download/upload URL, resulting in an "unsupported protocol scheme"
error.

With this commit it supports both absolute and relative.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants