Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Plack and multiple domains

by szabgab (Priest)
on Feb 17, 2012 at 19:02 UTC ( #954591=perlquestion: print w/replies, xml ) Need Help??
szabgab has asked for the wisdom of the Perl Monks concerning the following question:

I am using Starman to host a web site. I would like to setup a couple of other domains on the same server and tell Starman to handle them. How can I do that? I think Starman cannot handle it alone so I thought I'd need a Plack::Middleware. I checked, but I could not find any that would do that. Have I missed it or do I misunderstand how this should work?

Update

I also asked on the IRC channel of Plack and they directed me to Plack::Builder which is just awesome.

Replies are listed 'Best First'.
Re: Plack and multiple domains
by chromatic (Archbishop) on Feb 17, 2012 at 19:25 UTC
Re: Plack and multiple domains
by moritz (Cardinal) on Feb 17, 2012 at 20:03 UTC

    If you don't want to change any application code, you could have separate instances of Starman listening at different ports, and then have a user-facing Apache instance that runs a reverse proxy for each subdomain.

    I use a similar setup for a host that started off with only Apache, and now forwards some domains to a Mojolicious application, and it works fine.

      If you don't want to change any application code, you could have separate instances of Starman listening at different ports, and then have a user-facing Apache instance that runs a reverse proxy for each subdomain.

      Or you could have a user-facing ngix/lighthttpd/perlbal instance that runs a reverse proxy for each subdomain :) Plack::Middleware::ReverseProxy

      example reverse proxy config for apache/apache2/ngix/lighthttpd http://www.omakase.org/perl/starmanreverseproxyab.html

      Perlbal / http://wiki.catalystframework.org/wiki/deployment/perlbal-starman-psgi

Re: Plack and multiple domains
by Anonymous Monk on Feb 17, 2012 at 19:21 UTC

    I think its just a matter of using

    --listen localhost --listen localpost --listen localfoobar
    and then having some Plack::App::URLMap dispatch apps based on Host: header ( PSGI SERVER_NAME or HTTP_HOST var)
    $urlmap->map( "http://localhost/" => $app1); $urlmap->map( "http://localpost/" => $app2); $urlmap->map( "http://localfoobar/" => $app3);

    I'm not sure you need the multiple --listen options if all the hostnames bind to the same IP

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://954591]
Approved by philipbailey
help
Chatterbox?
[Your Mother]: Stick with what you know. Or post a SOPW and if it's not complicated I guarantee someone will answer; me if it's straightforward and no one else gets it better first.
[1nickt]: ++YourMother (Grammar Vigilante of Bristol)
[Lady_Aleena]: Um, how does grep do multiline? print "$file:$_" if grep { /get_(array|hash| data)\(.+\)/ } $_; only returns the same 18 lines the command line grep does.
[Lady_Aleena]: my scratchpad has what I have so far.
[choroba]: what do you mean by multiline?
[Discipulus]: thanks 1nickt!
[choroba]: grep is a filter, it selects elements from a list based on a boolean condition
[moritz]: you need to read the file in one go to do a multiline regex match
[erix]: ha ha, I like the Vigilante
[Lady_Aleena]: Forget it. I'm getting angry with it.

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (12)
As of 2017-05-23 19:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?