haiwen / seafile

High performance file syncing and sharing, with also Markdown WYSIWYG editing, Wiki, file label and other knowledge management features.
http://seafile.com/
Other
12.25k stars 1.54k forks source link

seahub behind apache with mod_proxy_fcgi does not work (no root domain) #1186

Closed zangetsu05 closed 8 years ago

zangetsu05 commented 9 years ago

Hi all, i have a problem to deploy seafile under Apache/mod_proxy_fcgi. The example in this issue https://github.com/haiwen/seafile/issues/884 work fine if you deploy seafile as the root domain, es: https://www.somesite.com/ but it doesn't work if you want to deploy it as a non-root domain.

Most of the errors i saw trying some configuration for a non root domain, are like page not find, not from apache but from seafile, or wrong uri in response without the /seafile/..., so i think that the key is the ProxyPass related to the fcgi module, but i don't know what's miss in the configuration. Can you help me to set the right configuration to work with this kind of url: https://www.somesite.com/seafile ?

Apache configuration:

[...]
#SEAFILE CONFIGURATION
Alias /filemedia /opt/seafile/seafile-server-latest/seahub/media
<Location /filemedia>
  ProxyPass !
  Require all granted
 </Location>

SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
SetEnvIf Request_URI . proxy-fcgi-pathinfo=1

# Seafile file server
ProxyPass "/filehttp" "http://127.0.0.1:8082"
ProxyPassReverse "/filehttp" "http://127.0.0.1:8082"

# Seafile WebDAV server
ProxyPass "/filedav" "http://127.0.0.1:8080/filedav"
ProxyPassReverse "/filedav" "http://127.0.0.1:8080/filedav"

# Seafile seahub server
SetEnvIf Request_URI . proxy-fcgi-pathinfo=1
ProxyPass "/seafile" "fcgi://127.0.0.1:8000/"
[...]

ccnet.conf

[General]
USER_NAME = SomeSiteUhOhh
ID = some-alphanumeric-id
NAME = SomeSiteUhOhh
SERVICE_URL = https://www.somesite.com/seafile
[...]

seahub_settings.py

FILE_SERVER_ROOT = 'https://www.somesite.com/filehttp'
SERVE_STATIC = False
MEDIA_URL = '/filemedia/'
SITE_ROOT = '/seafile/'
[...]

seafdav.conf

[WEBDAV]
enabled = true
port = 8080
fastcgi = false
share_name = /filedav

In the end i'm trying to merge the configuration from the manual http://manual.seafile.com/deploy/deploy_seahub_at_non-root_domain.html and http://manual.seafile.com/deploy/https_with_apache.html and the rewrite of the configuration of Apache to use the mod_proxy_fcgi described on this issue https://github.com/haiwen/seafile/issues/884 .

melkor0 commented 9 years ago

A problem, which happened to me too is in your Apache configuration.

You have:

ProxyPass "/seafile" "fcgi://127.0.0.1:8000/"

To access it on a non-root domain it should be:

ProxyPass "/seafile" "fcgi://127.0.0.1:8000/seafile"

Note the the matching trailing slash / missing trailing slash.

zangetsu05 commented 9 years ago

Hi, thanks for the answer, one of the test i made, was the same conf you wrote but it does not work, the result is a not working uri for seafile: https://www.somesite.com/seafile/accounts/login?next=/seafile/seafile/

seafile-problem

Every time i change the conf to find the right way for a non root domain i remove the directory /tmp/seahub_cache/ and the file seahub_settings.pyc, just to be shure that the cache start fresh.

zangetsu05 commented 9 years ago

And searching the log file i found this in the seahub_django_request.log: 2015-04-20 17:45:20,408 [WARNING] django.request:144 get_response Not Found: /seafile/

I think that the "fcgi://127.0.0.1:8000/seafile" is wrong, or we need something like a rewrite rule to pass the uri to seahub without the "/seafile" part. Am I wrong ?

melkor0 commented 9 years ago

I appears, that there is some 'Slash'-Problem. When comparing your screenshot, with mine, I can see, that there is something different in the address bar:

seafile-working

Yours seems to be missing a slash in [...]login/?next[...]

Just asking: Does Apache load the module proxy_fcgi_module? Nevermind, if it wasn't loaded, you would get an Error code 500.

Can you give the Apache config with which you produced this error

2015-04-20 17:45:20,408 [WARNING] django.request:144 get_response Not Found: /seafile/?

On another note: If you plan on using the Seafile client, you may run into difficulties. According to the manual ( http://manual.seafile.com/deploy/deploy_http_sync.html ) the fileserver path seafhttp is hard coded

zangetsu05 commented 9 years ago

The config posted on the first comment is what I'm testing to work behind Apache and in non root domain. Yes the mod is running otherwise you have a gateway error or a conf error. I know that the path fhttp is hardcoded, is not a problem.

melkor0 commented 9 years ago

I can almost exactly reproduce your problem (only the line numbers of the warning don't match). By using this:

ProxyPass /seafile fcgi://127.0.0.1:8000/

I get the following error in my seahub_django_request.log and no login window:

2015-04-21 08:26:57,434 [WARNING] django.request:146 get_response Not Found: /seafile/

By using the line from my first comment:

ProxyPass /seafile fcgi://127.0.0.1:8000/seafile

everything runs fine.

Can you edit your Apache config that it matches this line (take extra care that both seafile are missing the trailing slash) once more and post the error message from seahub_django_request.log?

zangetsu05 commented 9 years ago

Now works, i made some test and if you put a / at the and of the fcgi config [...]8000/seafile/ everything go crazy. And also i saw sometimes that if you made this kind of change and forget to clean the cache file, also can create a problem. Thanks a lot for your help! If isn't a problem for you i'll propose a change on the manual for the part "Non root domain" to show a conf if you use a mod_proxy_fcgi.

kb3dow commented 8 years ago

I also had the same issue (with non root domain - was driving me nuts after following the documentation till I saw this). The documentation at http://manual.seafile.com/deploy/deploy_seahub_at_non-root_domain.html needs to be fixed to reflect ProxyPass /seafile fcgi://127.0.0.1:8000/seafile

shoeper commented 8 years ago

You can create a PR at https://github.com/haiwen/seafile-docs