![]() |
|
We don't bite newbies here... much | |
PerlMonks |
Dancer2 App Deployment through Apache Proxyby choroba (Cardinal) |
on May 20, 2025 at 15:53 UTC ( [id://11165066]=perlquestion: print w/replies, xml ) | Need Help?? |
choroba has asked for the wisdom of the Perl Monks concerning the following question:
I wrote a Dancer2 application to be used by about 10 people from work. It ran fine on http://localhost, but the pages needed to be available from the outside world. Our IT admin told me the standard practice is to run it on a virtual host and use Apache's mod_proxy. Dancer2::Manual::Deployment even mentions such a possibility, so I followed the instructions. I included to config.yml, and the admin configured the proxy similarly as shown in the manual (see Using-Apache's-mod_proxy of Dancer2::Manual::Deployment. I was given a prefix under which the app would be running, e.g. https://example.com/prefix/login. But it doesn't work correctly. For example, the css files are ignored. Or rather, they can't be found. The main.tt template was created with the following link (part of the initial scaffolding):
But the request.uri_base doesn't expand to /prefix, it remains empty. Similarly, I use Dancer2::Plugin::Auth::Tiny for user authentication. Again, I almost copied verbatim the synopsis code:
But again, when I try to open the page, the authentication plugin redirects the browser to /login instead of /prefix/login. I was able to fix the problems by
Mentioning the prefix in the config definitely feels wrong. Hardcoding the prefix into the app? It also means the app can't be run locally on localhost for testing anymore. How should I properly write the app, configure it, and configure Apache to make it work both locally and in production, without hardcoding the prefix anywhere in the app? Interestingly, all Python flask and whatever apps written by other colleagues run as written without problems.
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Back to
Seekers of Perl Wisdom
|
|