jump to navigation

Virtual Hosts with Jboss / Apache / ColdFusion March 25, 2009

Posted by scoopseven in ColdFusion, Linux, MediaPost.
add a comment
So I needed to do something that I used to consider simple. I had www.mysite.com up and running with Apache / Jboss / ColdFusion and I wanted to create a virtual host, sitetwo.mysite.com to point the same configuration as www.mysite.com. I used to do this easily in IIS by creating a new Host Header entry under the website properties in IIS. Not so simple with the new configuration.
Step 1: Setup the DNS record. All starts with the CNAME record pointing sitetwo.mysite.com to www.mysite.com.
Step 2: Let Apache know about sitetwo.mysite.com.
ServerName www.mysite.com
ServerAlias sitetwo #added this line to Apache .conf file.
After doing updating the Apache .conf file and restarting Apache, you should be able to get to sitetwo.mysite.com but since JBoss hasn’t been setup to deal with it, you’ll get some annoying JBoss error that says the site hasn’t been configured in JBoss.
Step 3: Modify jboss-web.xml. For my install, this file was located in JBoss/server/default/deploy/mysite.war/WEB-INF/.
<jboss-web>
<context-root> /</context-root>
<virtual-host>www.mysite.com</virtual-host>
<virtual-host>sitetwo.mysite.com</virtual-host>
</jboss-web>
After I added the virtual host line for sitetwo.mysite.com and restarted JBoss I could access the new site aok. Here’s the BIG caveat. When you go to sitetwo.mysite.com/cfide/administrator, you’re presented with a complete *separate copy* of your original ColdFusion settings. If you have scheduled tasks setup, be careful, now there’s two of them, so they’ll run twice unless you delete them from your new administrator.  And be super careful of deleting your scheduled tasks!  After I did that, they disappeared from both of my administrators, so make sure you backup your scheduled tasks. You have two different ColdFusion administrators now, so be aware of caching, scheduled tasks, debugging, logins, etc.

Spidering and Saving Images with CFHTTP and CFFILE March 11, 2009

Posted by scoopseven in ColdFusion, Linux, MediaPost.
add a comment

Goal: To spider a site (our own site) and save all image files from the pages on that site to a hard disk on another server.

Thanks to Ben Nadel for showing me the way on this one.  For some reason the path/file attributes on cfhttp were not allowing me to save a image file to the hard disk on our linux (CentOS) server. I thought I could save the file using cfcontent somehow, which led me to Ben’s post. Never thought to just save the binary stream using cffile. Not sure if there was a permissions problem or what, but here’s the work-around.

<!— Grab the image file. —>
<cfhttp
method=”get”
url=”http://www.myurl.com/someimage.jpg”
useragent=”#CGI.http_user_agent#”
getasbinary=”yes”
result=”objGet”  />

<!— Save the image file. —>
<cffile action=”write” 
output=”#objGet.FileContent#” 
mode=”777″ 
file=”/mypath/myimage.jpg”>

This worked like a charm.  Again, not sure if this was cfhttp doesn’t support the “mode” attribute or what, but it helped immensely.  Thanks, Ben.