Skip to content

Running as part of another server #162

@hmhealey

Description

@hmhealey

Instead of running an image proxy as a standalone process, I was looking at having it run as part of another server (in my case, Mattermost) so that the other server handles the HTTP requests and then calls out to the image proxy to actually get the image. Since the only public method of the Proxy type is ServeHTTP, this isn't possible right now without possibly some weird logic to fake a request.

Would you accept a PR that makes the changes required for that? I haven't tested these changes yet, but it seems like it would require changes to:

  1. Make Proxy.serveImage public and have it take an image URL as the second parameter instead of an http.Request.
  2. Similarly, make NewRequest take an image URL and remove the Request.Original field since it is no longer passed down
  3. Move the referrer check out of Proxy.allowed and into Proxy.ServeHTTP so that it can still be checked when we have the original request

Alternatively, to avoid some of those changes (in particular, changing the public fields of the Request), we could

  1. Make Proxy.serveImage public and have it take an explicit image URL in addition to the request
  2. Have NewRequest use the explicit URL if it exists (ServeHTTP would pass nil) or otherwise use the original request URL as it does now
  3. Have Proxy.allowed skip the referrer check if there is no original request provided

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions