strangeness with Dancer prefix and apache proxy
I have the following in my apache2 conf file <VirtualHost *:80> ServerName my.computer.edu DocumentRoot "/path/to/Sites" <Proxy *> Options FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Proxy> SetEnv force-proxy-request-1.0 1 SetEnv proxy-nokeepalive 1 ProxyPreserveHost On ProxyPass /d/apps http://127.0.0.1:25012 ProxyPassReverse /d/apps http://127.0.0.1:25012 </VirtualHost> When I go to http://my.computer.edu/d/apps/js/app.js the log shows request: GET //js/app.js from 127.0.0.1 in ../Dancer/Handler.pm l. 52 When I go to http://127.0.0.1:25012/js/app.js the log shows request: GET /js/app.js from 127.0.0.1 in ../Dancer/Handler.pm l. 52 Why do I get to leading slashes in the first request above? Additionally, when I go to http://my.computer.edu/d/apps I get a correct response (the double slashes notwithstanding). However, when I go to http://my.computer.edu/d/apps/foo then I get a 404. My perl code is like so package apps; use Dancer ':syntax'; use Dancer::Plugin::Database; load_app 'eb', prefix => '/foo'; -- Puneet Kishor
On Feb 5, 2012, at 3:00 PM, Puneet Kishor wrote:
I have the following in my apache2 conf file
<VirtualHost *:80> ServerName my.computer.edu DocumentRoot "/path/to/Sites"
<Proxy *> Options FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Proxy>
SetEnv force-proxy-request-1.0 1 SetEnv proxy-nokeepalive 1 ProxyPreserveHost On
ProxyPass /d/apps http://127.0.0.1:25012 ProxyPassReverse /d/apps http://127.0.0.1:25012 </VirtualHost>
When I go to http://my.computer.edu/d/apps/js/app.js the log shows request: GET //js/app.js from 127.0.0.1 in ../Dancer/Handler.pm l. 52
When I go to http://127.0.0.1:25012/js/app.js the log shows request: GET /js/app.js from 127.0.0.1 in ../Dancer/Handler.pm l. 52
Why do I get to leading slashes in the first request above?
Additionally, when I go to http://my.computer.edu/d/apps I get a correct response (the double slashes notwithstanding). However, when I go to http://my.computer.edu/d/apps/foo then I get a 404. My perl code is like so
package apps;
use Dancer ':syntax'; use Dancer::Plugin::Database;
load_app 'eb', prefix => '/foo';
In fact, my second problem (404) is because of the first problem. Looking at the logs trying to match `//foo' against /(?^:^(?^:^\/foo(?:\/)?$)$)/ in ../Dancer/Route.pm l. 84 fails because of the double slash. Suggestions? -- Puneet Kishor
Hi, i had your trailing slash problem this week and i just corrected my handler regexs to something like '/foo\/?', so that you don't get the 404. As far as i know, Apache proxypassreverse handles the problem with a 302. For example, an HTTP redirection often takes place when a user (or author) forgets a trailing slash in a URL. So the response to a request for http://www.example.com/app1/foo proxies to http://internal.example.com/foowhich generates a response: HTTP/1.1 302 Found Location: http://internal.example.com/foo/ (etc) But from the outside world, the net effect of this is a "No such host" error. The proxy needs to re-map the Location header to its own address space and return a valid URL HTTP/1.1 302 Found Location: http://www.example.com/app1/foo/ The command to enable such rewrites in the HTTP Headers is ProxyPassReverse. The Apache documentation suggests the form: src- http://www.apachetutor.org/admin/reverseproxies regards, -- Tiago Quintela On 5 February 2012 21:00, Puneet Kishor <punk.kish@gmail.com> wrote:
I have the following in my apache2 conf file
<VirtualHost *:80> ServerName my.computer.edu DocumentRoot "/path/to/Sites"
<Proxy *> Options FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Proxy>
SetEnv force-proxy-request-1.0 1 SetEnv proxy-nokeepalive 1 ProxyPreserveHost On
ProxyPass /d/apps http://127.0.0.1:25012 ProxyPassReverse /d/apps http://127.0.0.1:25012 </VirtualHost>
When I go to http://my.computer.edu/d/apps/js/app.js the log shows request: GET //js/app.js from 127.0.0.1 in ../Dancer/Handler.pm l. 52
When I go to http://127.0.0.1:25012/js/app.js the log shows request: GET /js/app.js from 127.0.0.1 in ../Dancer/Handler.pm l. 52
Why do I get to leading slashes in the first request above?
Additionally, when I go to http://my.computer.edu/d/apps I get a correct response (the double slashes notwithstanding). However, when I go to http://my.computer.edu/d/apps/foo then I get a 404. My perl code is like so
package apps;
use Dancer ':syntax'; use Dancer::Plugin::Database;
load_app 'eb', prefix => '/foo';
-- Puneet Kishor _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
participants (2)
-
Puneet Kishor -
Tiago Quintela