Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serve from several domains #72

Open
daftaupe opened this issue Jan 15, 2020 · 4 comments
Open

Serve from several domains #72

daftaupe opened this issue Jan 15, 2020 · 4 comments

Comments

@daftaupe
Copy link

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,

@daftaupe
Copy link
Author

daftaupe commented Jan 15, 2020

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.

@depado
Copy link
Owner

depado commented Jan 15, 2020

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?

@daftaupe
Copy link
Author

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

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

@depado
Copy link
Owner

depado commented Jan 15, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants