Set global site root behind reverse proxy

1,538 views
Skip to first unread message

Ashex

unread,
Jan 17, 2013, 3:06:10 AM1/17/13
to sea...@googlegroups.com
Hello,

I've been using Seafile on my home network and want to set it up so I can sync to it when I'm elsewhere but am having trouble setting it up with my Apache instance.

In a nutshell, I've got multiple service I access behind a reverse proxy and I'd like to add seafile to it as /seafile.

I did some digging in the wiki and found this page of config options. I set SITE_ROOT to /seafile and using a standard reverse proxy with mod_proxy I was able to get the page to load, however none of the page content did since the media directory was still pointing to /media as opposed to /seafile/media

Now, I would like to do this properly with fastcgi, however it's not entirely clear from the wiki page how I would go about doing it if the url were /seafile as opposed to simply /

Would anyone be able to provide some advice/assistance? The final setup would have seafile accessible externally at domain.com:8080/seafile, the same url inside the network would resolve to the internal IP.


Thanks!

ZhengXie

unread,
Jan 17, 2013, 6:08:41 AM1/17/13
to sea...@googlegroups.com
On Jan 17, 2013, at 4:06 PM, Ashex <as...@chipnick.com> wrote:

Hello,

I've been using Seafile on my home network and want to set it up so I can sync to it when I'm elsewhere but am having trouble setting it up with my Apache instance.

In a nutshell, I've got multiple service I access behind a reverse proxy and I'd like to add seafile to it as /seafile.

I did some digging in the wiki and found this page of config options. I set SITE_ROOT to /seafile and using a standard reverse proxy with mod_proxy I was able to get the page to load, however none of the page content did since the media directory was still pointing to /media as opposed to /seafile/media


You should also overwrite the MEDIA_URL to /seafile/media in seahub_settings.py

My apologies, I forgot to add this variable in Wiki.

Ahmed Osman

unread,
Jan 17, 2013, 2:59:14 PM1/17/13
to sea...@googlegroups.com
Okay, I set MEDIA_URL and that kind of worked.

Those url for those files is now correct (/seafile/media/) however it's not returning any content. Apache log shows a 404 being returned for each file. Here is the reverse proxy I'm using in httpd:


<Location /seafile>
ProxyPass http://localhost:8000/seafile
ProxyPassReverse http://localhost:8000/seafile
</Location>

And seahub_settings.py

HTTP_SERVER_ROOT = "http://192.168.1.50:8082"
SITE_ROOT = '/seafile/'
MEDIA_URL = '/seafile/media/'
SERVE_STATIC = False



-Ahmed Osman


--
You received this message because you are subscribed to the Google Groups "seafile" group.
To post to this group, send email to sea...@googlegroups.com.
To unsubscribe from this group, send email to seafile+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/seafile?hl=en.
 
 

ZhengXie

unread,
Jan 18, 2013, 12:42:17 AM1/18/13
to sea...@googlegroups.com
HI,

Here is how I configure with Apache proxy,

In seahub_settings.py:

SERVE_STATIC = False
MEDIA_URL = '/seafmedia/'
SITE_ROOT = '/seafile/'

Here, I use /seafmedia/ as MEDIA_URL instead of /seafile/media/ , SITE_ROOT is the root of seahub, which in this case is '/seafile/'.

In httpd:

<VirtualHost *:80>
  ServerName 127.0.0.1
  DocumentRoot /var/www
  Alias /seafmedia  /Users/xiez/dev/seahub/media

  <Location /seafile>
  ProxyPassReverse http://localhost:8000/seafile
  </Location>

  <Directory /Users/xiez/dev/seahub/media>
      Options +Indexes
      Allow from all
  </Directory>
  
</virtualhost>

Here , I use Alias to let Apache serve static files, please change the second argument to your path.  And don't forget to add 'Allow from all', otherwise you will get 403 error.

I've tested on my develop machine, it works well.

Ahmed Osman

unread,
Jan 18, 2013, 12:57:50 AM1/18/13
to sea...@googlegroups.com
Thanks! That worked perfectly. Looking back using /seafile/media for MEDIA_ROOT wasn't a very good idea.


-Ahmed Osman

Ahmed Osman

unread,
Jan 18, 2013, 6:02:41 PM1/18/13
to sea...@googlegroups.com
Continuing this thread instead of starting a new one.

Seahub is working great, I'm able to login and browse/manage files. However I can't download files!

I've figured out that it's because the files are being served by seafile which is running on a different port. In my case, seahub is being accessed through the reverse proxy on mydomain.com/seafile.
I setup a reverse proxy for seafile to mydomain.com/files but this isn't working since the url includes the port that seafile is running on (8082). If I remove the port from the url I'm able to download the file.

I don't really see a method for working around this as seafile is embedding the port in the generated url rather than using the relative path. I could open a port on the firewall for 8082 but I'd prefer to keep it all on the same port for security reasons.


This is all taking place on the new 1.4.1 release.



-Ahmed Osman

ZhengXie

unread,
Jan 18, 2013, 10:57:05 PM1/18/13
to sea...@googlegroups.com
Hi,

In 1.4.1 release, you need to modify the function get_httpserver_root in seahub/utils/__init__.py from:

def get_httpserver_root():
    """
    Get seafile http server address and port from seaserv.

    """
    return HTTP_SERVER_ROOT if HTTP_SERVER_ROOT else ''

to:

def get_httpserver_root():
    """
    Get seafile http server address and port from seaserv.

    """

We will add a new configure variable in next release.

Regards,
Zheng Xie

Ahmed Osman

unread,
Jan 19, 2013, 1:22:12 AM1/19/13
to sea...@googlegroups.com
That did it for me although when I specified mydomain.com/files I was getting invalid download urls like 


I used http://mydomain.com which solved the issue.


Thanks again!


-Ahmed Osman

Ashex

unread,
Jan 23, 2013, 9:36:47 PM1/23/13
to sea...@googlegroups.com
Looks like my choice of http://mydomain.com is causing problems.


When I try to upload a file it's missing the /files root and I end up with a url like this:




Additionally I setup seafile on my work pc (first machine not connecting to seafile on the LAN) and the download task is stuck at "connecting server..."



-Ahmed Osman



-Ahmed Osman


To unsubscribe from this group, send email to seafile+unsubscribe@googlegroups.com.


--
You received this message because you are subscribed to the Google Groups "seafile" group.
To post to this group, send email to sea...@googlegroups.com.
To unsubscribe from this group, send email to seafile+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "seafile" group.
To post to this group, send email to sea...@googlegroups.com.
To unsubscribe from this group, send email to seafile+unsubscribe@googlegroups.com.


--
You received this message because you are subscribed to the Google Groups "seafile" group.
To post to this group, send email to sea...@googlegroups.com.
To unsubscribe from this group, send email to seafile+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "seafile" group.
To post to this group, send email to sea...@googlegroups.com.
To unsubscribe from this group, send email to seafile+unsubscribe@googlegroups.com.

Lingtao Pan

unread,
Jan 24, 2013, 6:17:31 AM1/24/13
to sea...@googlegroups.com
On Thursday, January 24, 2013 10:36:47 AM UTC+8, Ashex wrote:

Additionally I setup seafile on my work pc (first machine not connecting to seafile on the LAN) and the download task is stuck at "connecting server..."


for trouble shooting this problem. 

ZhengXie

unread,
Jan 24, 2013, 8:44:28 AM1/24/13
to sea...@googlegroups.com
Hi Ahmed,

Here is how I configure seafile httpserver using Nginx proxy with seafile 1.4.1:

    location /seafile {
        fastcgi_pass    127.0.0.1:8000;
        fastcgi_param   SCRIPT_FILENAME     $document_root$fastcgi_script_name;
        fastcgi_param   PATH_INFO           $fastcgi_script_name;

        fastcgi_param   SERVER_PROTOCOL         $server_protocol;
        fastcgi_param   QUERY_STRING        $query_string;
        fastcgi_param   REQUEST_METHOD      $request_method;
        fastcgi_param   CONTENT_TYPE        $content_type;
        fastcgi_param   CONTENT_LENGTH      $content_length;
        fastcgi_param   SERVER_ADDR         $server_addr;
        fastcgi_param   SERVER_PORT         $server_port;
        fastcgi_param   SERVER_NAME         $server_name;

        access_log      /var/log/nginx/seahub.access.log;
        error_log       /var/log/nginx/seahub.error.log;
    }

    location /seafhttp {
        rewrite /seafhttp/(.*) /$1 break;
        proxy_pass  http://127.0.0.1:8082;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        proxy_redirect off;
        proxy_buffering off;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    }

I deloy seafile under http://mydomain/seafile, and I deply seafile httpserver under http://mydomain/seafhttp, I also make some changes in seahub/utils/__init__.py (hopefully, you won't need to do this in the coming seafile 1.4.5):

def get_httpserver_root():
    """
    Get seafile http server address and port from seaserv.

    """

With these changes, I can download/upload files from seahub.

Regards,
Zheng Xie


--
You received this message because you are subscribed to the Google Groups "seafile" group.
To post to this group, send email to sea...@googlegroups.com.
To unsubscribe from this group, send email to seafile+u...@googlegroups.com.

Ahmed Osman

unread,
Jan 26, 2013, 2:57:10 AM1/26/13
to sea...@googlegroups.com
Thanks for the details, I'm still using the httpd proxy (considering switching to Nginx since all I use httpd for is reverse proxy), I updated my firewall to expose ccnet and seaf-server. Also corrected things so file uploads kind of work but there's a timeout issue causing the upload to partially fail. I'm going to look into it a bit more in the morning.

As for the client, it wasn't working even after creating a new library and downloading. HOWEVER, after restarting the client everything synchronized like magic. This behavior mystifies me.


-Ahmed Osman
Reply all
Reply to author
Forward
0 new messages