Hello, I'm having problems deploying a simple dancer app with Apache+Starman. Even using the most basic setup doesn't seem to work properly - the "request.uri_for()" returns "http://localhost:3000" instead of the virtual server name. I tried following the varied instructions in Dancer::Deployment, but that are just too many options, or perhaps I don't understand how the different parts connect. What I did is: ## 1. Create a new app $ dancer -a foo $ cd foo ## 2. Start the server with Starman $ plackup -s Starman -l 127.0.0.1:3000 ./bin/app.pl ## In Apache, my configuration is; <VirtualHost *:80> ServerName xxxx.cshl.edu ServerAlias xxxx ProxyPass / http://localhost:3000/ ProxyPassReverse / http://localhost:3000/ </VirtualHost> That's it, nothing more, nothing less. I can see the main Dancer website stub ("Perl is Dancing" etc.), but every link inside the HTML page (e.g. the CSS file) points to "http://localhost:3000" instead of "http://xxxx.cshl.edu" - so none of the links is working. Any suggestion will be highly appreciated, Thanks, -assaf.
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... there's also a proxypreservehost setting in apache proxy which helps. http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypreservehost Alex On Mon, 2011-11-07 at 15:16 +0000, Assaf Gordon wrote:
Hello,
I'm having problems deploying a simple dancer app with Apache+Starman.
Even using the most basic setup doesn't seem to work properly - the "request.uri_for()" returns "http://localhost:3000" instead of the virtual server name. I tried following the varied instructions in Dancer::Deployment, but that are just too many options, or perhaps I don't understand how the different parts connect.
What I did is:
## 1. Create a new app $ dancer -a foo $ cd foo
## 2. Start the server with Starman $ plackup -s Starman -l 127.0.0.1:3000 ./bin/app.pl
## In Apache, my configuration is; <VirtualHost *:80> ServerName xxxx.cshl.edu ServerAlias xxxx
ProxyPass / http://localhost:3000/ ProxyPassReverse / http://localhost:3000/ </VirtualHost>
That's it, nothing more, nothing less. I can see the main Dancer website stub ("Perl is Dancing" etc.), but every link inside the HTML page (e.g. the CSS file) points to "http://localhost:3000" instead of "http://xxxx.cshl.edu" - so none of the links is working.
Any suggestion will be highly appreciated, Thanks, -assaf. _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
On Mon, 2011-11-07 at 18:04 +0000, Alex Knowles wrote:
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...
there's also a proxypreservehost setting in apache proxy which helps.
http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypreservehost
sorry - i should have said - may help (although apache docs say don't use it :) ) a
Alex
On Mon, 2011-11-07 at 15:16 +0000, Assaf Gordon wrote:
Hello,
I'm having problems deploying a simple dancer app with Apache+Starman.
Even using the most basic setup doesn't seem to work properly - the "request.uri_for()" returns "http://localhost:3000" instead of the virtual server name. I tried following the varied instructions in Dancer::Deployment, but that are just too many options, or perhaps I don't understand how the different parts connect.
What I did is:
## 1. Create a new app $ dancer -a foo $ cd foo
## 2. Start the server with Starman $ plackup -s Starman -l 127.0.0.1:3000 ./bin/app.pl
## In Apache, my configuration is; <VirtualHost *:80> ServerName xxxx.cshl.edu ServerAlias xxxx
ProxyPass / http://localhost:3000/ ProxyPassReverse / http://localhost:3000/ </VirtualHost>
That's it, nothing more, nothing less. I can see the main Dancer website stub ("Perl is Dancing" etc.), but every link inside the HTML page (e.g. the CSS file) points to "http://localhost:3000" instead of "http://xxxx.cshl.edu" - so none of the links is working.
Any suggestion will be highly appreciated, Thanks, -assaf. _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
_______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
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
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
Hi Assaf! Is there any way I can convince you to help us improve the deployment docs to include your case? It's important for us to be able to cater to the common deployment procedures and if you weren't able to get all the information from the deployment docs, it definitely means they need revamping. I'm willing to make you dinner! :) S.
sawyer x wrote, On 11/07/11 14:33:
Is there any way I can convince you to help us improve the deployment docs to include your case? It's important for us to be able to cater to the common deployment procedures and if you weren't able to get all the information from the deployment docs, it definitely means they need revamping.
Actually, I find the "deployment" page very confusing, and ironically almost every option I tried (with Apache) didn't work "out of the box" for me. I'm can to try to organize it differently, and rewrite most of the apache section (and just copy-paste the others because I have no experience with them). The question is: are you guys willing to incorporate such changes, or just want some minor touch-ups on the apache+starman section? The content order that makes sense to me: 1. short section on "Direct(CGI/FastCGI,PSGI) vs Stand-Alone (Proxy)" 2. Direct (CGI/fastCGI/PSGI) per server - nginx - lighttpd - apache 3. StandAlone / Proxy - Intro: front-end (e.g. apache) vs. back-end (e.g. plackup+startman+dancer) - Back-ends: - ./bin/app.pl (for development) - Plackup (Starman, Twiggy, etc.) - Front-ends: - Apache + mod_proxy - Apache + mod_rewrite - nginx - lighttpd 4. Advanced options: - Create Service: Ubic, Daemon-tools - Multiple applications on same server - Plack::Builder - CGI/FastCGI - Apache + mod_rewrite - nginx / lighttpd ? - Non-root deployment - Serving static content directly - Apache + mod_rewrite - nginx / lighttpd ? - Performance - CGI vs. Starman ? Alternatively, mix 2+3 and organize by server type instead of by CGI/StandAlone. Let me know what you think, comments are welcomed from everyone, -gordon
Hi, Assaf Gordon wrote, On 11/07/11 17:43:
sawyer x wrote, On 11/07/11 14:33:
Is there any way I can convince you to help us improve the deployment docs to include your case? It's important for us to be able to cater to the common deployment procedures and if you weren't able to get all the information from the deployment docs, it definitely means they need revamping.
I'm can to try to organize it differently, and rewrite most of the apache section (and just copy-paste the others because I have no experience with them).
Here's my first short the the Deployment document (not completed yet). https://github.com/agordon/Dancer/blob/topic/deployment_pod/lib/Dancer/Deplo... I can vouch for the Apache parts, but have no clue about nginx or lighttpd. If you spot any errors, let me know. -gordon
Hi, On Nov 7, 2011, at 17:43, "Assaf Gordon" <gordon@cshl.edu<mailto:gordon@cshl.edu>> wrote: sawyer x wrote, On 11/07/11 14:33: It's important for us to be able to cater to the common deployment procedures and if you weren't able to get all the information from the deployment docs, it definitely means they need revamping. I can to try to organize it differently, and rewrite most of the apache section (and just copy-paste the others because I have no experience with them). Here's my first shot at reorganizing the deployment pod: https://github.com/agordon/Dancer/blob/topic/deployment_pod/lib/Dancer/Deplo... It's not complete yet, but it has the content in a way I wish I had it when I started with Dancer and new nothing about psgi/plack/starman/etc. Comments and corrections are welcomed, - gordon
Hi, Assaf Gordon wrote, On 11/07/11 17:43:
sawyer x wrote, On 11/07/11 14:33:
It's important for us to be able to cater to the common deployment procedures and if you weren't able to get all the information from the deployment docs, it definitely means they need revamping.
I'm can to try to organize it differently, and rewrite most of the apache section (and just copy-paste the others because I have no experience with them).
Here's my first shot at rewriting the Deployment pod: https://github.com/agordon/Dancer/blob/topic/deployment_pod/lib/Dancer/Deplo... Comments and corrections are welcomed, -gordon
On Mon, 2011-11-07 at 18:59 +0000, 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.
oh awesome! Sorry, I was in a bit of a rush when I wrote my reply. We had exactly this problem, specifically for proxying ssl content (yay! security!). However we're running a little behind on dancer version so were missing the behind_proxy setting, we did a bump and it didn't work, so just set the apache preserve stuff. But it's handy to know it's not just us :) a
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 _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
On Nov 7, 2011, at 9:16 AM, Assaf Gordon wrote:
Hello,
I'm having problems deploying a simple dancer app with Apache+Starman.
Even using the most basic setup doesn't seem to work properly - the "request.uri_for()" returns "http://localhost:3000" instead of the virtual server name. I tried following the varied instructions in Dancer::Deployment, but that are just too many options, or perhaps I don't understand how the different parts connect.
What I did is:
## 1. Create a new app $ dancer -a foo $ cd foo
## 2. Start the server with Starman $ plackup -s Starman -l 127.0.0.1:3000 ./bin/app.pl
## In Apache, my configuration is; <VirtualHost *:80> ServerName xxxx.cshl.edu ServerAlias xxxx
ProxyPass / http://localhost:3000/ ProxyPassReverse / http://localhost:3000/ </VirtualHost>
That's it, nothing more, nothing less. I can see the main Dancer website stub ("Perl is Dancing" etc.), but every link inside the HTML page (e.g. the CSS file) points to "http://localhost:3000" instead of "http://xxxx.cshl.edu" - so none of the links is working.
Any suggestion will be highly appreciated,
Just suggestions here, because with "almost" exactly the same as above, my apps work just fine. Here is the "almost" part. I start Starman with different settings. I recall that I did try it with -l option, and it funked out for me, although I don't recall the specifics of the errors I got. I remember being quite mystified until I went back to my original way of calling Starman, and that works. Here is how I launch it my @cmd = ( "plackup", "-s Starman", "-p $port", "-w 10", "-E $env", "--access-log $dir_logs/$access", "--error-log $dir_logs/$error", "-D", "--pid $dir_pids/$pid", "-a $dir_appl/$app/bin/app.pl" ); system( join(" ", @cmd) ); The main different from your way is that I use `-p $port` instead of `-l $host:$port` Other than that, my settings are the same as yours. -- Puneet Kishor
participants (6)
-
Alex Knowles -
Assaf Gordon -
Gordon, Assaf -
Ogden -
Puneet Kishor -
sawyer x