Depoloying Seafile behind an Apache reverse proxy on another server

Hi,

I’m trying to deploy Seafile behind an Apache reverse proxy while Seafile and Apache are installed on different servers. (on the same LAN)
Seafile would be hosted on mydomain.com/seafile
Until now I’ve had these installed on the same server for a few years and everything worked fine.

I think I’ve almost got it working but there is still one problem. Whenever I open the Seafile page in my browser the CSS is not loaded. The page then looks like this:

I think this is because of the following line in my apache config:
Alias /seafmedia /home/seafile/seafile-server-latest/seahub/media

Since the Seafile installation is not on that server anymore, Apache won’t be able to read that directory.
So I was wondering if it is possible to also proxy this directory to the other server.
Any help would be appreciated.

Here is the rest of my Apache config:

<VirtualHost *:443>

    Alias /seafmedia  /home/seafile/seafile-server-latest/seahub/media

    RewriteEngine On

    <Location /seafmedia>
        ProxyPass !
        Require all granted
    </Location>

#   seafile fileserver
    ProxyPass /seafhttp http://xx.xx.xx.xx:8082
    ProxyPassReverse /seafhttp http://xx.xx.xx.xx:8082
    RewriteRule ^/seafhttp - [QSA,L]

#   seahub
    SetEnvIf Request_URI . proxy-fcgi-pathinfo=unescape
    SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
    ProxyPreserveHost On
    ProxyPass /seafile http://xx.xx.xx.xx:8000/seafile
    ProxyPassReverse /seafile http://xx.xx.xx.xx:8000/seafile
</VirtualHost>

I want to start out this reply by saying, I don’t use Apache, but I am trying to accomplish the same thing you are doing here, running on a separate VM. I happen to use Nginx for pretty much everything webwise.

Anyway, I ran into this very thing and you are correct. The media is located on the seafile server. I read someplace people suggest (as the right way to address it) you can setup the media on memcached, I went a little simpler route by proxying the media path back to seafile and it works fine.

Here’s a link to my configuration on pastebin, I think you can glean from there enough to help you piece together how I did it at least, and good luck!

https://pastebin.com/JbvM9fPe

Thank you for the input @ledoktre
I can’t find anything about setting up media in memcached, can you recall where you read that?

So I’ve been trying a few things like adding a proxy setting in my apache config for /seafmedia.
I still haven’t figured it out but this is what I got so far.

I added the following to the config:
ProxyPass /seafmedia http://xx.xx.xx.xx:8000/seafmedia

Also tried it like this:
ProxyPass /seafmedia http://xx.xx.xx.xx:8000/seafmedia ProxyPassReverse /seafmedia http://xx.xx.xx.xx:8000/seafmedia

Now whenever I try to access Seafile via the webbrowser it spits out the following in the seahub log on the Seafile server:
2020-05-16 19:50:17,975 [WARNING] django.request:152 get_response Not Found: /seafmedia/img/favicon.ico 2020-05-16 19:50:24,947 [WARNING] django.request:152 get_response Not Found: /seafmedia/css/seafile-ui.css 2020-05-16 19:50:24,948 [WARNING] django.request:152 get_response Not Found: /seafmedia/css/sf_font3/iconfont.css 2020-05-16 19:50:24,955 [WARNING] django.request:152 get_response Not Found: /seafmedia/css/seahub.css 2020-05-16 19:50:24,959 [WARNING] django.request:152 get_response Not Found: /seafmedia/assets/scripts/lib/jquery.min.a09e13ee94d5.js 2020-05-16 19:50:24,961 [WARNING] django.request:152 get_response Not Found: /seafmedia/js/jq.min.js 2020-05-16 19:50:24,962 [WARNING] django.request:152 get_response Not Found: /seafmedia/assets/scripts/lib/jquery.simplemodal.55150926fcd1.js 2020-05-16 19:50:24,967 [WARNING] django.request:152 get_response Not Found: /seafmedia/js/base.js 2020-05-16 19:50:24,972 [WARNING] django.request:152 get_response Not Found: /seafmedia/img/seafile-logo.png 2020-05-16 19:50:24,979 [WARNING] django.request:152 get_response Not Found: /seafmedia/img/login-bg.jpg 2020-05-16 19:50:24,999 [WARNING] django.request:152 get_response Not Found: /seafmedia/js/jq.min.js 2020-05-16 19:50:25,025 [WARNING] django.request:152 get_response Not Found: /seafmedia/js/base.js

Now if I understand correctly the content in /seafile-server-latest/seahub/media is not actively hosted by Seahub, hence the Alias option in Apache.
Would it be possible to host these files with another webserver (like lighthttpd) on the Seafile host and then proxy it through the main webserver?
(Please excuse me if I’m talking nonsense)

Good news, I got it working!

So I finally got the time to try the suggestion I made in my last post. I installed apache on my CentOS Seafile server, and made a virtualhost just for seahub. Then I made a proxy configuration on the Ubuntu webserver and now everything works as expected!

For anyone wondering, the config looks like this now:
Apache config on the Seafile server running CentOS:

<VirtualHost *:80>
   ServerName www.mydomain.dns
   DocumentRoot /var/www/html

   Alias /seafmedia  /home/seafile/seafile-server-latest/seahub/media

   RewriteEngine On

    <Location /seafmedia>
       Require all granted
   </Location>
</VirtualHost>

Apache config on the webserver running Ubuntu:

<VirtualHost *:443>
#SEAFILE
#Alias /seafmedia  /home/seafile/seafile-server-latest/seahub/media

    RewriteEngine On

    ProxyPass /seafmedia http://xx.xx.xx.xx/seafmedia
    ProxyPassReverse /seafmedia http://xx.xx.xx.xx/seafmedia

    <Location /seafmedia>
        Require all granted
    </Location>

#seafile fileserver
    ProxyPass /seafhttp http://xx.xx.xx.xx:8082
    ProxyPassReverse /seafhttp http://xx.xx.xx.xx:8082
    RewriteRule ^/seafhttp - [QSA,L]

#Seahub
   SetEnvIf Request_URI . proxy-fcgi-pathinfo=unescape
    SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
    ProxyPreserveHost On
    ProxyPass /seafile http://xx.xx.xx.xx:8000/seafile
    ProxyPassReverse /seafile http://xx.xx.xx.xx:8000/seafile
</VirtualHost>