depado/goploader

Serve from several domains

daftaupe opened this issue · 4 comments

Hello,

I think it would be helpful to be able to specify several servernames, so that one instance of goploader could be used for different domains/subdomains.
Would it be possible to form the returned URL of the document via the Host header in the coming request ?

Regards,

I sort of did it with the following changes :


diff --git a/server/views/resources.go b/server/views/resources.go
index 039237d..4521492 100644
--- a/server/views/resources.go
+++ b/server/views/resources.go
@@ -82,7 +82,7 @@ func CreateC(c *gin.Context) {
                return
        }
        res.OnCreated(c)
-       c.String(http.StatusCreated, "%s/v/%s/%s\n", utils.ServerURI(c), res.Key, k)
+       c.String(http.StatusCreated, "%s/v/%s/%s\n", utils.DetectScheme(c) + "://" + c.Request.Host, res.Key, k)
 }
 
 // ViewC handles the file views for encrypted files

What do you think about that modification ?

For the record it requires to use proxy_set_header Host $host; when reverse-proxying with nginx.

Hello,
First of all thanks for your interest in this project.

I found this middleware that maybe could be used to have a more generic way of handling that. (In which case, we could just use location.Get(c) instead of the utils package). This middleware also allows to define which headers are taken into account and supports defaults. I feel that it would make things simpler.

What do you think?

@Depado that sounds much better than my quick hack indeed !

But unfortunately I don't have that much time to hack on goploader :/

I'll have a look when I have some time then :)