On Nov 7, 2011, at 12:59 PM, Assaf Gordon wrote:
Eureka!
Alex Knowles wrote, On 11/07/11 13:04:
There's a behind_proxy setting in config which is probably exactly for this situation:
http://search.cpan.org/~xsawyerx/Dancer-1.3080/lib/Dancer/Config.pm#behind_p...
Thanks Alex, "behind_proxy" is indeed *almost* the solution. I found it by looking at the code (it is *not* mentioned anywhere in Dancer::Deployment), but still couldn't get it to work properly, until now.
The problem is that for some reason, the apache headers are listed in "request->env" as HTTP_X_FORWARDED_HOST instead of "X_FORWARDED_HOST". Not sure if this is a problem with my apache configuration, or PSGI/Plack program or something else. But because of that, "behind_proxy" was not working.
I've added a patch that fixes the "behind_proxy" in this situation, but also warns if "behind_proxy" is defined and the X_FORWARDED_HOST is not found - because this case should not be just ignored.
https://github.com/agordon/Dancer/commit/5b0e9562acacaee18fd6519c32c9d33f8c2...
With this patch, I'm able to solve all my previous deployment questions: 1. Multiple dancer applications under one server 2. Multiple dancer applications not under the root directory 3. Serve static files directly with apache (not through dancer)
So if you please agree to include this patch, I'll be happy to change (improve?) the deployment pod with more examples.
regards, -gordon
Thank you for this. I also had the same problem and uri_for was returning http://localhost:3000/ instead of the proper server name.. I also had turned on behind_proxy and my Apache configuration was nothing out of the ordinary. I was using Starman along with Apache: <VirtualHost …> ... <Proxy *> Order deny,allow Allow from allow </Proxy> ProxyPass / http://localhost:3031/ ProxyPassReverse / http://localhost:3031/ </VirtualHost> Last week, people on IRC told me that my Apache was bonked and that I should use hard links instead of the uri_for to bypass this issue - I was going to look into it, but thank you for this patch. I hope this gets included. Thank you Gordon - just wanted to confirm I also had the same issues but chalked it up to my installation. Will try your patch. Ogden