Seafile Behind a Caddy Reverse Proxy not on localhost


(Max Steffens) #1

Hey,

So I got Seafile up and running on a virtual machine of mine and I am trying to use caddy as a reverse proxy for it but the problem is that its not on local host of Seafile its in its own virtual machine. I can access the Seafile interface and download the doc but when I want to upload something to the server I get a network error and I believe it has to do with not specifying what the /media directory should proxy to. Now everything I look up on Caddy(even NGINX and Apache for that matter) as a reverse proxy for Seafile I always get examples for them on the local host. So I am wondering if anyone knows how to set up my caddy file to proxy the location of the media directory to a different host from local?

Here is my caddyfile below never mind the /request proxy thats going to another site.

mydomain.com {
   tls my@email.com
   proxy /request internalip:3700 {
      transparent
   }
   proxy / internalip:8000 {
      transparent
   }
   proxy /seafhttp internalip:8082 {
      transparent
      without /seafhttp
   }
}

(Matthew Fay) #2

Almost all configuration applies equally to localhost and external hosts. The only difference in Caddy’s configuration should be that the upstream server you’re proxying to is specified as the external host instead of localhost or 127.0.0.1 etc.

You’ll need to make sure that all the URIs that Seafile uses are properly proxied to the Seafile host.


(Max Steffens) #3

Okay so this is what I’m missing from the example below.

example.com/media {
    root /home/user/haiwen/seafile-server-latest/seahub/media
    gzip
}

So how would I send that off from local host to another ip and am I misunderstanding something?


(Matthew Fay) #4

If you’re not hosting the files locally any more, so you need to proxy to a web server that is, just like the proxies in your original post.

The example you just gave would be the kind of the config you’d run on Caddy on the other host, responding to the Caddy proxying to it.


(Max Steffens) #5

hmmm so i just need to figure out what that 3rd option is on the seafile built in webserver so i can proxy the media requests to it from caddy?


(Matthew Fay) #6

There needs to be some kind of web server serving up the files. Either Caddy needs to do it off disk, or Caddy needs to proxy to a webserver that does serve them off disk.

Whether that’s Seafile’s built in webserver and you proxy from Caddy to that, or whether you set up another Caddy on the Seafile host - I’m not sure what’s most feasible.


(Max Steffens) #7

but i would have like 2 proxy caddy proxys then in a row basically.


(Matthew Fay) #8

Nothing particularly wrong with that.

It’s just a consequence of having the files on a different host.

Far more complicated proxy chains have been deployed in the past, and will be deployed in future. I frequently proxy from Caddy to other Caddies or nginx’s or Apaches or just other Go web apps in Docker containers.