The wiki suggests setting up varnish which seems not to have the capability to modify the content as it comes back out. Also it feels like a brittle solution to have to inspect the traffic and doing string replacement - I might get all the places now but not in the future.
After doing some research I’ve found that hostname part can be solved already. By having the proxy server pass through the original host header that is the response you get back from EventStore
On windows this just works:
curl http://localhost:2113/streams/%24all -u admin:changeit -H ‘Host: abc.com:1234’
Gives me links like: http://abc.com:2113/streams/%24stats-127.0.0.1%3A2113/39963
On the linux build I get a Bad Request (Invalid Host) response. I was able to overcome this by starting EventStore like so:
./clusernode --http-prefixes=“http://*:2114” (note the different port it still seems to bind to localhost:2113 which means you can’t also do *:2113)
Most reverse proxies seems to support passing through the Host header unchanged: http://httpd.apache.org/docs/current/mod/mod_proxy.html#proxypreservehost. This looks trivial to do with varnish as well.
The next challenge is the port. There doesn’t appear to be a nice way to do this translation. From what I could see the url helpers for MVC and WebAPI don’t support anything for this either. Some proxy servers seem to send through the external port as an additional header. Amazon’s Elastic Load Balancer adds an X-Forwarded-Port header which eventstore could use for generating URLs if it’s present.
http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/TerminologyandKeyConcepts.html (right down the bottom). Something similar should be doable with varnish pretty easily.
So my (hopefully) small proposal is can we have EventStore support a header (X-Forwarded-Port?) from the proxy server that would allow the Port of generated URLs to be controlled. While we are doing this it could probably support X-Forwarded-Proto for http vs https. I am happy to put together a pull request if this sounds reasonable.
If I’ve missed something and it’s possible to have EventStore behind a reverse proxy as is please let me know. (I guess I could have the reverse proxy and event store on different machines and the same port)