gost / server

GOST - Go implementation of OGC SensorThings API
MIT License
61 stars 19 forks source link

using HTTP header X-Forwarded-Server #83

Closed bertt closed 7 years ago

bertt commented 7 years ago

We currently use the gost_server_external_uri environment variable for sending absolute url's in the responses. When running GOST behind a proxy server, we can also use HTTP header X-Forwarded-Server for constructing the absolute url's. In this case, customers don't have to set the gost_server_external_uri

Proposal: 1] Use gost_server_external_uri if available, if not: 2] Use X-Forwarded-Server if available, if not: 3] use default (localhost)

bertt commented 7 years ago

Code to be added:

ExternalURI = r.Header.Get("X-Forwarded-For")

With some checks

bertt commented 7 years ago

maybe easier method: create middleware function that's called last and inspects the response. And replaces the url's in the response.

bertt commented 7 years ago

see pr https://github.com/Geodan/gost/pull/93 for middleware option

bertt commented 7 years ago

fixed

bertt commented 7 years ago

when running in Docker this seems not working (X-Forwarded-For header not set in nginx?), have to check it again

bertt commented 7 years ago

header X-Forwarded-For is indeed empty, but why

bertt commented 7 years ago

cannot fix it easily now. testing on http://labs.play-with-docker.com/ , but cannot get the outside serverurl. Workaround is to set external_uri in environment vars in docker-compose file.