slatibart has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I have apache running and need to run a mojolicious app under the path /rules
This is the apache config part
Very simply mojolicious script with a route to / and a route to /userProxyRequests Off ProxyPreserveHost On ProxyPass /rules http://localhost:3000/ keepalive=On ProxyPassReverse /rules http://localhost:3000/ RequestHeader set X-Forwarded-HTTPS "0"
Generated html looks good.app->hook(before_dispatch => sub { my ( $c ) = @_; my $url = $c->req->url; my $base = $url->base;# push @{ $base->path }, 'rules'; $base->path->trailing_slash(1); $url->path->leading_slash(0); }); get '/' => sub { my $self = shift; my $host = $self->tx->remote_address; my $content = "Host: $host"; $self->stash(content=>$content); $self->render('index'); }; get '/user' => sub { my $self = shift; my $host = $self->tx->remote_address; my $content = "Host: $host"; $self->stash(content=>$content); $self->render('index'); }; app->start; __DATA__ @@ index.html.ep % layout 'default'; <%== $content %> @@ layouts/default.html.ep <!DOCTYPE html> <html lang="en"> <head> <title>Test</title> </head> <body> %= button_to Home => '/' %= button_to User => '/user' %= link_to Home => '/' %= link_to User => 'user' %= content </body> </html>
Using the home button / links works but for route /user mojolicous throws an error.<!DOCTYPE html> <html lang="en"> <head> <title>Test</title> </head> <body> <form action="/rules"><input type="submit" value="Home"></form> <form action="/rules/user"><input type="submit" value="User"></form> <a href="/rules">Home</a> <a href="/rules/user">User</a> Host: 127.0.0.1 </body> </html>
"None of these routes could generate a response for your GET request for //user, maybe you need to add a new one?"
Where is that extra slash coming from and how to get rid of that ?
Bonus question. If I add another layer push @{ $base->path }, 'all/rules'; all slashes are transformed.
Any idea why ?<form action="/all%2Frules"><input type="submit" value="Home"></form> <form action="/all%2Frules/user"><input type="submit" value="User"></f +orm> <a href="/all%2Frules">Home</a> <a href="/all%2Frules/user">User</a>
Thanks for your help.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Mojolicious, apache reverse proxy
by daxim (Curate) on Sep 19, 2019 at 15:19 UTC | |
by slatibart (Sexton) on Sep 20, 2019 at 07:59 UTC | |
Re: Mojolicious, apache reverse proxy
by Your Mother (Archbishop) on Sep 21, 2019 at 07:42 UTC | |
by slatibart (Sexton) on Sep 23, 2019 at 09:11 UTC | |
Re: Mojolicious, apache reverse proxy
by trwww (Priest) on Sep 21, 2019 at 04:09 UTC | |
by Your Mother (Archbishop) on Sep 21, 2019 at 04:18 UTC | |
by trwww (Priest) on Sep 21, 2019 at 05:46 UTC | |
by Your Mother (Archbishop) on Sep 21, 2019 at 07:37 UTC | |
Re: Mojolicious, apache reverse proxy
by Anonymous Monk on Sep 21, 2019 at 11:39 UTC | |
by slatibart (Sexton) on Sep 23, 2019 at 09:34 UTC |
Back to
Seekers of Perl Wisdom