Global app-wide "prefix" settings
Hello, (Somewhat related to the previous thread of "Deploying many many apps") Is there a way to specify a application-wide "prefix" settings ? The "prefix" keyword affects only the routes subroutines, but not the static/public files. For example, With WSGI/Pylon, they have a "prefix" settings that can be specified in the INI file, and that affects all the components of the application (including static files). This allows the following: 1. Write your application as usual (so route '/' is really '/', and images are /images/XXXX.jpg and javascripts are in /javascript/XXXX.js, etc.) 2. Add a "prefix" setting to the INI file (e.g. "prefix=dancer"), now: the root route because "/dancer/", images come from /dancer/images/XXXX.jpg javascripts come from /dancer/javascripts/XXXXX.js css files come from /dancer/css/XXXXXX.css etc. 3. In Apache (or NGinx), do something like: RewriteRule ^/dancer/images/(.*) /home/gordon/projects/my_dancer_app/public/images/$1 [L] RewriteRule ^/dancer/javascripts/(.*) /home/gordon/projects/my_dancer_app/public/javascripts/$1 [L] RewriteRule ^/dancer/css/(.*) /home/gordon/projects/my_dancer_app/public/css/$1 [L] RewriteRule ^/dancer(.*) http://localhost:3000$1 [P] The outcome: 1. Static content is served by Apache directly, doesn't even go to the application (based on a "rewrite_rule"). 2. Multiple applications can be deployed with different URL-prefix, without changing a single line of code in the application (just in the INI file). Does Dancer support something similar ? I haven't deployed a production server yet, but I'm planning do do so with several applications running on the same server (with different prefixes), and after reading Dancer::Deployment I'm still not sure what's the recommended way to do so. suggestions are very welcomed, -gordon
On Wed, Sep 14, 2011 at 8:13 PM, Assaf Gordon <gordon@cshl.edu> wrote:
Is there a way to specify a application-wide "prefix" settings ? The "prefix" keyword affects only the routes subroutines, but not the static/public files.
I think you're referring to "appdir". It can be set from a config file and/or from your application. Sorry for the long reply. S.
sawyer x wrote, On 09/21/2011 02:40 AM:
On Wed, Sep 14, 2011 at 8:13 PM, Assaf Gordon <gordon@cshl.edu <mailto:gordon@cshl.edu>> wrote:
Is there a way to specify a application-wide "prefix" settings ? The "prefix" keyword affects only the routes subroutines, but not the static/public files.
I think you're referring to "appdir". It can be set from a config file and/or from your application.
I don't think so (unless I'm misreading the meaning of "appdir"). It's my impression that "appdir" refers to physical directories, where the application will find the relevant resource files. What I'm looking for is a way to globally add a *URL* prefix to the entire application. <begin long explanation> Others have mentioned deploying multiple dancer applications on the same server. It seems the most common solution is to have a virtual host, and the root directory of the virtual host goes to each individual dancer app. So that: http://app1.cshl.edu/ => Application 1 http://app2.cshl.edu/ => Application 2 http://app3.cshl.edu/ => Application 3 Even if they are all virtual hosts running on the same physical server. That's OK, but I'm looking for a way do have multiple Dancers run from the same host, but with different URL prefixes: http://server.cshl.edu/app1/ => application 1 http://server.cshl.edu/app2/ => application 2 http://server.cshl.edu/app3/ => application 3 When it comes to routes, that is easily doable with the "prefix" keyword. But the "prefix" keyword doesn't take care of static files (javascripts/images/css) - those will still be rendered (due to "request.uri_base" in the template) as http://server.cshl.edu/css/style.css instead of http://server.cshl.edu/app1/css/style.css (per dancer application). Obviously, one can edit every template file to make sure the URL has the application's prefix. But it's an ugly hard-coded solution, and requires synchronization between the perl code's "prefix" and the template's hardocded URLs. I want an application-wide "prefix" setting (in the config file, or similar), that would affect every part of the application. <begin long example> -1- If I create a new dancer application, and add the following route: get '/mydata' => sub { (whatever) } And my server is "http://server.cshl.edu", then by default, the application's URLs would be: http://server.cshl.edu/ => root route http://server.cshl.edu/mydata => my code http://server.cshl.edu/images/ => static images http://server.cshl.edu/css/ => static CSS http://server.cshl.edu/javascript/ => static javascripts -2- If I add a "prefix => "/app1" " statement in my code, the URLs become: http://server.cshl.edu/app1 => root route http://server.cshl.edu/app1/mydata => my code http://server.cshl.edu/images/ => static images http://server.cshl.edu/css/ => static CSS http://server.cshl.edu/javascript/ => static javascripts The URL for the route changed, but not for the static files. -3- What I'm looking for is a way to specify that "/app1" should now be a prefix for everything, including static files. and preferably, be able to do it from the configuration file - this would allow me to change the URL of deployed applications without changing a single line of code. Thanks for reading so far, -gordon
Sorry for the late reply. I have been tremendously busy lately and anything bearing the words "long explanation" is doomed to be delayed on my reading list. Anyway, I think you have separated concerns here: app level and server level. I think people here have been mixing those unjustifiably and causing themselves a lot of havoc by trying to get it to work. We are not all the best web server administrators, but sometimes that's where the solution is, and although we can make app-level shortcuts, we should try to avoid them. The app should remain a self-contained fixed (I'd even say "pristine") app. It should not worry about the deployment needs that you specifically have, on any specific server. This is why we have PSGI and this is also the mindset of Dancer. In effect we could write a prefix for static files as well, or a keyword to allow using the prefix on static files. However, this is a server problem and therefor my opinion is to refuse any such change in Dancer. Instead you should configure your server to meet your needs. I personally suggest using the "Alias" configuration option in Apache. I hope this clears it up for you. If you have any more questions on this, feel free to ask, and I hope I could help you with them. Good luck on your web quest! :) Sawyer.
Hi Sawyer, sawyer x wrote, On 09/28/2011 01:38 PM:
[...] Instead you should configure your server to meet your needs. I personally suggest using the "Alias" configuration option in Apache.
I hope this clears it up for you. If you have any more questions on this, feel free to ask, and I hope I could help you with them.
I'm definitely not a web-server administrator, so I'd appreciate any tips how how to do that without changing the application. The simplest scenario: Two dancers applications, running on the same machine, and the url is http://server.cshl.edu . I can't add subdomain (e.g. http://app1.server.cshl.edu), and can't open ports other than 80. So the way to access the applications will be: http://server.cshl.edu/app1 and http://server.cshl.edu/app2 This will go through apache with reverse-proxy rule back to dancer applications (each running on a different port, with starman). What do I need to change in order for the static files to be served from "http://server.cshl.edu/app1/images" instead of "http://server.cshl.edu/images" (which is the way templates will be rendered using "request.uri_base" and "request.uri_for" ? Thanks again, -gordon
Hi, On Wed, Sep 28, 2011 at 6:54 PM, Assaf Gordon <gordon@cshl.edu> wrote:
What do I need to change in order for the static files to be served from "http://server.cshl.edu/app1/images" instead of "http://server.cshl.edu/images" (which is the way templates will be rendered using "request.uri_base" and "request.uri_for" ?
Inside the server.cshl.edu Apache VirtualHost configuration block, try this: Alias /app1/images /path/to/app1/public/images Alias /app2/images /path/to/app2/public/images Best regards, -- Pedro Melo @pedromelo http://www.simplicidade.org/ http://about.me/melo xmpp:melo@simplicidade.org mailto:melo@simplicidade.org
Pedro Melo wrote, On 09/28/2011 02:14 PM:
Hi,
On Wed, Sep 28, 2011 at 6:54 PM, Assaf Gordon <gordon@cshl.edu> wrote:
What do I need to change in order for the static files to be served from "http://server.cshl.edu/app1/images" instead of "http://server.cshl.edu/images" (which is the way templates will be rendered using "request.uri_base" and "request.uri_for" ?
Inside the server.cshl.edu Apache VirtualHost configuration block, try this:
Alias /app1/images /path/to/app1/public/images Alias /app2/images /path/to/app2/public/images
I understand the apache configuration part, but not the dancer part: In my Dancer/Template-Toolkit file (e.g. "views/layout/main.tt"), I'm still using: <img src="[% request.uri_base %]/images/pic.jpg"/> and <link rel="stylesheet" href="[% request.uri_base %]/css/style.css" /> So the link (inside the generated HTML that the user will receive) will contain: http://server.cshl.edu/images/pic.jpg and http://server.cshl.edu/css/style.css And so that alias (in the apache configuration) will not 'catch' it. -gordon
On Wed, Sep 28, 2011 at 9:22 PM, Assaf Gordon <gordon@cshl.edu> wrote:
I understand the apache configuration part, but not the dancer part:
In my Dancer/Template-Toolkit file (e.g. "views/layout/main.tt"), I'm still using: <img src="[% request.uri_base %]/images/pic.jpg"/> and <link rel="stylesheet" href="[% request.uri_base %]/css/style.css" />
So the link (inside the generated HTML that the user will receive) will contain: http://server.cshl.edu/images/pic.jpg and http://server.cshl.edu/css/style.css
Indeed that's what the users will get. Then they have to run another request to the server to retrieve it, and that's when they hit the Alias rule which tells the apache "they're asking for /images/ but they actually want /app/images".
sawyer x wrote, On 09/28/2011 03:33 PM:
On Wed, Sep 28, 2011 at 9:22 PM, Assaf Gordon <gordon@cshl.edu <mailto:gordon@cshl.edu>> wrote:
I understand the apache configuration part, but not the dancer part:
In my Dancer/Template-Toolkit file (e.g. "views/layout/main.tt <http://main.tt>"), I'm still using: <img src="[% request.uri_base %]/images/pic.jpg"/> and <link rel="stylesheet" href="[% request.uri_base %]/css/style.css" />
So the link (inside the generated HTML that the user will receive) will contain: http://server.cshl.edu/images/pic.jpg and http://server.cshl.edu/css/style.css
Indeed that's what the users will get. Then they have to run another request to the server to retrieve it, and that's when they hit the Alias rule which tells the apache "they're asking for /images/ but they actually want /app/images".
I must be missing something big, because I just don't get it :) 1. If the user gets <src img="http://server.cshl.edu/images/pic.jpg"> and then retrieves it, an alias rule "Alias /app1/images /path/to/app1/public/images" (as suggested by Pedro Melo) will *not* catch it - unless I don't understand the meaning of Apache's "Alias". 2. If I have two dancer applications, and both generate URLS of "http://server.cshl.edu/images/pic.jpg" - how is it possible for apache to tell if this image belongs to the first application or the second ? Perhaps I'm not explaining myself well. I'll try to ask it in a different way: Has anyone been able to deploy a Dancer application *not* under the server's root URL, without changing code/templates in the Dancer application itself ? That is: 1. create default dancer application. the index route's URL is "/" the images URL is "/images/*" the CSS URL is "/css/*" 2. SOME CONFIGURATION in Apache ?? 3. The root URL of the entire application is now "/gordon/": the index route's URL is "/gordon/" the images URL is "/gordon/images/*" the CSS URL is "/gordon/css/*" What should I do in step 2 ?
Has anyone been able to deploy a Dancer application *not* under the server's root URL, without changing code/templates in the Dancer application itself ?
To deploy under a specific directory you need to make all your templates aware of it <% request.uri_base %>/images Hope this helps
That is: 1. create default dancer application. the index route's URL is "/" the images URL is "/images/*" the CSS URL is "/css/*"
2. SOME CONFIGURATION in Apache ??
3. The root URL of the entire application is now "/gordon/": the index route's URL is "/gordon/" the images URL is "/gordon/images/*" the CSS URL is "/gordon/css/*"
What should I do in step 2 ?
_______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
On Wed, Sep 28, 2011 at 1:07 PM, Assaf Gordon <gordon@cshl.edu> wrote:
sawyer x wrote, On 09/28/2011 03:33 PM:
On Wed, Sep 28, 2011 at 9:22 PM, Assaf Gordon <gordon@cshl.edu <mailto: gordon@cshl.edu>> wrote:
I understand the apache configuration part, but not the dancer part:
In my Dancer/Template-Toolkit file (e.g. "views/layout/main.tt < http://main.tt>"), I'm still using: <img src="[% request.uri_base %]/images/pic.jpg"/> and <link rel="stylesheet" href="[% request.uri_base %]/css/style.css" />
So the link (inside the generated HTML that the user will receive) will contain: http://server.cshl.edu/images/pic.jpg and http://server.cshl.edu/css/style.css
Indeed that's what the users will get. Then they have to run another request to the server to retrieve it, and that's when they hit the Alias rule which tells the apache "they're asking for /images/ but they actually want /app/images".
I must be missing something big, because I just don't get it :)
1. If the user gets <src img="http://server.cshl.edu/images/pic.jpg"> and then retrieves it, an alias rule "Alias /app1/images /path/to/app1/public/images" (as suggested by Pedro Melo) will *not* catch it - unless I don't understand the meaning of Apache's "Alias".
2. If I have two dancer applications, and both generate URLS of " http://server.cshl.edu/images/pic.jpg" - how is it possible for apache to tell if this image belongs to the first application or the second ?
Perhaps I'm not explaining myself well. I'll try to ask it in a different way:
Has anyone been able to deploy a Dancer application *not* under the server's root URL, without changing code/templates in the Dancer application itself ?
That is: 1. create default dancer application. the index route's URL is "/" the images URL is "/images/*" the CSS URL is "/css/*"
2. SOME CONFIGURATION in Apache ??
3. The root URL of the entire application is now "/gordon/": the index route's URL is "/gordon/" the images URL is "/gordon/images/*" the CSS URL is "/gordon/css/*"
What should I do in step 2 ?
The only thing I can think of is to rewrite the html on the way out such that all calls to /images/ get the prefix. The problem is that all your templates are hard coding a path to a resource on the server. You're telling the browser what resource to request and you're giving it an "absolute" path. You could also give them "relative" paths such as: <img src="images/foo.png"> Which will work fine as long as you don't have any routes that are deeper. Why don't you just have a configuration parameter in your config file that says "path" and then use that instead of "[% request.uri_base %]"? I don't quite get why you're using uri_base anyway. All you have to do is say: <img src="/images/foo.png"> and it will default to pulling from the same server the page was served from. You could mod all your templates to say something like: <img src="[% images_path %]/foo.png"> And then control it via config. I agree that this isn't something Dancer should strive to support, it's really an odd request (hard coding resource URLs and then expecting the app layer to rewrite outbound HTML or something).
_______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
Brian E. Lozier wrote, On 09/28/2011 04:14 PM:
On Wed, Sep 28, 2011 at 1:07 PM, Assaf Gordon <gordon@cshl.edu <mailto:gordon@cshl.edu>> wrote:
Has anyone been able to deploy a Dancer application *not* under the server's root URL, without changing code/templates in the Dancer application itself ?
The only thing I can think of is to rewrite the html on the way out such that all calls to /images/ get the prefix. The problem is that all your templates are hard coding a path to a resource on the server. You're telling the browser what resource to request and you're giving it an "absolute" path. You could also give them "relative" paths such as:
<img src="images/foo.png">
Which will work fine as long as you don't have any routes that are deeper.
Why don't you just have a configuration parameter in your config file that says "path" and then use that instead of "[% request.uri_base %]"? I don't quite get why you're using uri_base anyway. All you have to do is say:
This configuration parameter is exactly what started this thread (The app-wide "prefix" setting - in the subject line) :) And I keep learning that it's a bad idea, but haven't yet understood how to do it without such parameter.
On Wed, Sep 28, 2011 at 1:17 PM, Assaf Gordon <gordon@cshl.edu> wrote:
Brian E. Lozier wrote, On 09/28/2011 04:14 PM:
On Wed, Sep 28, 2011 at 1:07 PM, Assaf Gordon <gordon@cshl.edu <mailto:
gordon@cshl.edu>> wrote:
Has anyone been able to deploy a Dancer application *not* under the
server's root URL,
without changing code/templates in the Dancer application itself ?
The only thing I can think of is to rewrite the html on the way out such
that all calls to /images/ get the prefix. The problem is that all your templates are hard coding a path to a resource on the server. You're telling the browser what resource to request and you're giving it an "absolute" path. You could also give them "relative" paths such as:
<img src="images/foo.png">
Which will work fine as long as you don't have any routes that are
deeper.
Why don't you just have a configuration parameter in your config file
that says "path" and then use that instead of "[% request.uri_base %]"? I don't quite get why you're using uri_base anyway. All you have to do is say:
This configuration parameter is exactly what started this thread (The app-wide "prefix" setting - in the subject line) :) And I keep learning that it's a bad idea, but haven't yet understood how to do it without such parameter.
I'm suggesting creating a new config variable for your apps, not reusing the prefix one. Although I'm not sure why you wouldn't want to use the prefix one, I'll go back and read the beginnings of the thread.
_______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
On Wed, Sep 28, 2011 at 1:22 PM, Brian E. Lozier <brian@massassi.com> wrote:
On Wed, Sep 28, 2011 at 1:17 PM, Assaf Gordon <gordon@cshl.edu> wrote:
Brian E. Lozier wrote, On 09/28/2011 04:14 PM:
On Wed, Sep 28, 2011 at 1:07 PM, Assaf Gordon <gordon@cshl.edu <mailto:
gordon@cshl.edu>> wrote:
Has anyone been able to deploy a Dancer application *not* under the
server's root URL,
without changing code/templates in the Dancer application itself ?
The only thing I can think of is to rewrite the html on the way out such
that all calls to /images/ get the prefix. The problem is that all your templates are hard coding a path to a resource on the server. You're telling the browser what resource to request and you're giving it an "absolute" path. You could also give them "relative" paths such as:
<img src="images/foo.png">
Which will work fine as long as you don't have any routes that are
deeper.
Why don't you just have a configuration parameter in your config file
that says "path" and then use that instead of "[% request.uri_base %]"? I don't quite get why you're using uri_base anyway. All you have to do is say:
This configuration parameter is exactly what started this thread (The app-wide "prefix" setting - in the subject line) :) And I keep learning that it's a bad idea, but haven't yet understood how to do it without such parameter.
I'm suggesting creating a new config variable for your apps, not reusing the prefix one. Although I'm not sure why you wouldn't want to use the prefix one, I'll go back and read the beginnings of the thread.
I read the thread, you said: "Obviously, one can edit every template file to make sure the URL has the application's prefix. But it's an ugly hard-coded solution, and requires synchronization between the perl code's "prefix" and the template's hardocded URLs. I want an application-wide "prefix" setting (in the config file, or similar), that would affect every part of the application." I think your best option is to either make your own config variable and put that in every template. You don't have to synchronize the templates and prefix setting, you only have to synchronize the new config variable you make and the prefix setting.
_______________________________________________
Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
Such as Git, it sounds complex but it is in fact relatively simple. You have a virtual host catching all requests to a domain name. It will put it in the context of the virtual host configuration block (<VirtualHost *:80>). You can specify the domain inside it: <VirtualHost *:80> ServerName mydomain.com ServerAlias www.mydomain.com </VirtualHost> Inside that context, you can have Aliases. These aliases assure that whenever someone requests one thing, Apache will actually submit them another. This helps when you put stuff in different locations but want the users to have the same requests. For example, you want the users to go to mydomain/cgi-bin/script.pl when in fact you want "cgi-bin" to be in a very specific place outside the regular directory. You can have that, and that's what people often use. 1. Put a virtual host for "mydomain" 2. Put an alias from "/myapp/images" to "/public/images" 3. Users reach: mydomain/myapp/images 4. Apache will actually go to /public/images to get the images instead of /myapp/images. It's that simple.
On Wed, Sep 28, 2011 at 1:18 PM, sawyer x <xsawyerx@gmail.com> wrote:
Such as Git, it sounds complex but it is in fact relatively simple.
You have a virtual host catching all requests to a domain name. It will put it in the context of the virtual host configuration block (<VirtualHost *:80>). You can specify the domain inside it: <VirtualHost *:80> ServerName mydomain.com ServerAlias www.mydomain.com </VirtualHost>
Inside that context, you can have Aliases. These aliases assure that whenever someone requests one thing, Apache will actually submit them another. This helps when you put stuff in different locations but want the users to have the same requests. For example, you want the users to go to mydomain/cgi-bin/script.pl when in fact you want "cgi-bin" to be in a very specific place outside the regular directory. You can have that, and that's what people often use.
1. Put a virtual host for "mydomain" 2. Put an alias from "/myapp/images" to "/public/images" 3. Users reach: mydomain/myapp/images 4. Apache will actually go to /public/images to get the images instead of /myapp/images.
It's that simple.
I think I understand what you're saying but I think you're misunderstanding the problem. The problem is that he wants to mount TWO apps under different directories: /prefix1/ /prefix2/ But each of these apps are requesting images like /images/image1.png, and the images overlap. He wants requests coming from /prefix1/ to service /prefix1/images/image1.png and requests from /prefix2/ to service /prefix2/images/image1.png even though there's no way to tell the server which "prefix" he's under given a request for /images/image1.png.
_______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
On Wed, Sep 28, 2011 at 11:21 PM, Brian E. Lozier <brian@massassi.com>wrote:
I think I understand what you're saying but I think you're misunderstanding the problem. The problem is that he wants to mount TWO apps under different directories:
Indeed perhaps I'm misunderstanding.
/prefix1/ /prefix2/
But each of these apps are requesting images like /images/image1.png, and the images overlap. He wants requests coming from /prefix1/ to service /prefix1/images/image1.png and requests from /prefix2/ to service /prefix2/images/image1.png even though there's no way to tell the server which "prefix" he's under given a request for /images/image1.png.
The solution would still be the same though. It's a server configuration problem. Put the public directory outside the applications, set up the aliases to the same directory. "Badaboom", as it were in The Fifth Element. :)
On Wed, Sep 28, 2011 at 1:26 PM, sawyer x <xsawyerx@gmail.com> wrote:
On Wed, Sep 28, 2011 at 11:21 PM, Brian E. Lozier <brian@massassi.com>wrote:
I think I understand what you're saying but I think you're misunderstanding the problem. The problem is that he wants to mount TWO apps under different directories:
Indeed perhaps I'm misunderstanding.
/prefix1/ /prefix2/
But each of these apps are requesting images like /images/image1.png, and the images overlap. He wants requests coming from /prefix1/ to service /prefix1/images/image1.png and requests from /prefix2/ to service /prefix2/images/image1.png even though there's no way to tell the server which "prefix" he's under given a request for /images/image1.png.
The solution would still be the same though. It's a server configuration problem. Put the public directory outside the applications, set up the aliases to the same directory. "Badaboom", as it were in The Fifth Element. :)
"Put an alias from "/myapp/images" to "/public/images"" Except that his HTML is coded such that requests for images are going to /images/ (please note the beginning "/" -- all requests are going to the root of the server) not /myapp/images/, so making an alias at /myapp/images/ to /something_else/images/ won't help. He's trying to use the same URL (http://myserver.com/images/foo.png) to serve different content based on whether it was requested from an html page at /prefix1/ or /prefix2/ -- the only way to do this would be for the request for the image to look at something like the referrer and serve the "right" image. Or modify his app to request different URLs and then there is no problem.
First, Brian - thank you! For a minute there I thought I was going mad, imagining non-existent problems that I can't seem to explain :) a minor breakthrough! This might have caused my confusion (especially after reading Alberto's email, that made it sound like it's already built-in): If I deploy using : === <Location /app1> SetHandler perl-script PerlHandler Plack::Handler::Apache2 PerlSetVar psgi_app /home/gordon/projects/dancer/bin/app.pl </Location> === Then indeed, "request.uri_base" will be "http://server.cshl.edu/app1" - and everything "just works" (including all the static files, they go under "/app1/images/*"). But if I deploy using just "./bin/app.pl" or using Plackup+starman, then "request.uri_base" is always root, regardless of the apache/reverse-proxy configuration. I haven't tested other deployment methods yet. I'll investigate some more... perhaps there's a way to make it work with Plackup+Starman . Thanks again everyone, -gordon
Hi, On Wed, Sep 28, 2011 at 8:33 PM, sawyer x <xsawyerx@gmail.com> wrote:
On Wed, Sep 28, 2011 at 9:22 PM, Assaf Gordon <gordon@cshl.edu> wrote:
I understand the apache configuration part, but not the dancer part:
In my Dancer/Template-Toolkit file (e.g. "views/layout/main.tt"), I'm still using: <img src="[% request.uri_base %]/images/pic.jpg"/> and <link rel="stylesheet" href="[% request.uri_base %]/css/style.css" />
So the link (inside the generated HTML that the user will receive) will contain: http://server.cshl.edu/images/pic.jpg and http://server.cshl.edu/css/style.css
Indeed that's what the users will get. Then they have to run another request to the server to retrieve it, and that's when they hit the Alias rule which tells the apache "they're asking for /images/ but they actually want /app/images".
err... No. Actually, the request.uri_base should be at this point /app1 ... When Apache proxys the request from /app1/something to dancer, he rewrites it as /something, and sets one header (I forget which one) with /app1, and that should be what request.uri_base returns. I'll setup something like this, and see if I can get it to work tomorrow morning, I need to sleep now. Bye, -- Pedro Melo @pedromelo http://www.simplicidade.org/ http://about.me/melo xmpp:melo@simplicidade.org mailto:melo@simplicidade.org
participants (5)
-
ambs -
Assaf Gordon -
Brian E. Lozier -
Pedro Melo -
sawyer x