Yep, I think it would. The problem is, what if I want a more complex 
transformation next time? Or just a different string other than "stage" 
inserted?

It's okay, this works well enough for me now.

On Jan 17, 2014, at 15:24 , Chris Pratt <thechrispr...@gmail.com> wrote:

> Wouldn't adding "(stage\.)?" to each host-alias-regexp and changing the 
> host-name to regexp allow it to work as you want it?  For example:
> 
>     <host regexp="(stage\.)?latencyzero.com" 
> root-directory="/lz/var/www/com/latencyzero">
>         
> <host-alias-regexp>^tycho.(stage\.)?latencyzero.com[\.]?$</host-alias-regexp>
>         
> <host-alias-regexp>^(www\.)?(stage\.)?latencyzero.com[\.]?$</host-alias-regexp>
>         <web-app id="/" document-directory="www"></webapp>
>     </host>
> 
> 
> On Fri, Jan 17, 2014 at 3:18 PM, Rick Mann <rm...@latencyzero.com> wrote:
> 
> On Jan 17, 2014, at 06:05 , Paul Cowan <co...@caucho.com> wrote:
> 
> >
> > On Jan 16, 2014, at 4:32 PM, Rick Mann <rm...@latencyzero.com> wrote:
> >
> >> I'm trying to update a virtual server that runs a handful of webapps in 
> >> Resin. The old machine was "tycho.latencyzero.com" and a bunch of DNS 
> >> entries point to it. The web apps are configured to respond to those 
> >> varying hostnames. The new machine temporarily has the name 
> >> "stage.latencyzero.com."
> >>
> >> I copied everything from the old machine to the new, including the resin 
> >> config file. Obviously, I can't just go to "stage.latencyzero.com", 
> >> because resin has no idea which webapp I really want.
> >>
> >> Is there any way to configure resin to rewrite a request with a host like 
> >> "foo.bar.latencyzero.com.stage.latencyzero.com" into a request for the 
> >> webapp that responds to "foo.bar.latencyzero.com," while keeping the 
> >> actual hostname intact for the purposes of rendering links in the pages, 
> >> etc.?
> >
> > Hi Rick,
> >
> > I'm not exactly understanding what you want to do, but it sounds like I a 
> > similar situation I had on one of my sites.  This configuration below is 
> > what I used.  The new real host is listed first in resin.xml, then the 
> > default host id="" with host-alias * will catch all, and the redirect regex 
> > will redirect to the new site while appending the requested URI.
> >
> >     <host id="foo" root-directory="hosts/foo">
> >       <host-alias-regexp>.*foo.com</host-alias-regexp>
> >       …
> >     </host>
> >
> >     <host id="" root-directory="hosts/default">
> >       <host-alias>*</host-alias>
> >       <web-app id="/" root-directory="webapps/ROOT">
> >         <resin:Redirect regexp="(.*)" target="http://www.foo.com$1"/>
> >         <resin:Redirect regexp="(.*)" target="https://www.foo.com$1";>
> >           <resin:IfSecure value="true"/>
> >         </resin:Redirect>
> >       </web-app>
> >     </host>
> >
> > Hope this helps,
> 
> Hmm, not sure. Basically, I have entries in resin.xml on machine 
> "tycho.latencyzero.com" like this:
> 
>     <host host-name="latencyzero.com" 
> root-directory="/lz/var/www/com/latencyzero">
>         <host-alias-regexp>^tycho.latencyzero.com[\.]?$</host-alias-regexp>
>         <host-alias-regexp>^(www\.)?latencyzero.com[\.]?$</host-alias-regexp>
>         <web-app id="/" document-directory="www"></webapp>
>     </host>
> 
>     <host id="comics\.roderickmann\.org\.?" 
> root-directory="/lz/var/www/org/roderickmann/comics">
>         <host-name>comics.roderickmann.org</host-name>
>         <web-app id="/" document-directory="."></webapp>
>     </host>
> 
>     <host host-name="www.roderickmann.org" 
> root-directory="/lz/var/www/org/roderickmann/www">
>         <host-alias-regexp>^(www\.)?roderickmann.org[\.]?$</host-alias-regexp>
>         <host-alias-regexp>^(www\.)?rickmann.org[\.]?$</host-alias-regexp>
>         <web-app id="/" document-directory="."></webapp>
>     </host>
> 
>     <host host-name="mgfb.roderickmann.org" 
> root-directory="/lz/var/www/org/roderickmann/mgfb">
>         <host-alias-regexp>^mgfb\.roderickmann.org[\.]?$</host-alias-regexp>
>         <host-alias-regexp>^blog\.roderickmann.org[\.]?$</host-alias-regexp>
>         <web-app id="/" document-directory="."></webapp>
>     </host>
> 
> I have DNS entries for all of the above that are all CNAMEs to 
> tycho.latencyzero.com.
> 
> I want to move all of those apps to a new machine (upgrading hardware and 
> OS), but I want to test it first. The machine is called 
> stage.latencyzero.com, and I need to make new DNS entries for each webapp 
> (perhaps adding "stage" to each name, or something). The most straightforward 
> thing would be simply to modify each name to add "stage" to them, but then 
> when I decide to make the new machine permanent, and change all the old DNS 
> entries to point to the new IP address, I'd have to modify the entries.
> 
> Or I could simply add host-aliases for all the new names.
> 
> But I was hoping there'd be a trick so that I only have to modify one line, 
> and each of the host entries would pick it up. I realize that might require 
> me to modify all the entries once (as you did with your redirects). But once 
> I do this once, it should work for similar changes in the future.
> 
> One thing I need to preserve: if I'm hitting one of my webapps through the 
> new name (e.g. "stage.mgfb.roderickmann.org" or whatever), when code in the 
> webapp uses the host name to render URIs, it needs to use that same hostname, 
> so that links point to the right place, and not back to the old instance.
> 
> All this discussion, of course, has taken longer than it would have to simply 
> modify the entries a couple times, but I was curious.
> 
> Thanks,
> Rick
> 
> 
> _______________________________________________
> resin-interest mailing list
> resin-interest@caucho.com
> http://maillist.caucho.com/mailman/listinfo/resin-interest
> 
> 
> _______________________________________________
> resin-interest mailing list
> resin-interest@caucho.com
> http://maillist.caucho.com/mailman/listinfo/resin-interest


-- 
Rick



Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

_______________________________________________
resin-interest mailing list
resin-interest@caucho.com
http://maillist.caucho.com/mailman/listinfo/resin-interest

Reply via email to