Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: Setting up virtual hosts
PostPosted: Sun Aug 05, 2012 9:58 am 
Offline
Newbie

Joined: Fri Jul 13, 2012 7:37 pm
Posts: 2
I'be bought 2 domains and want both to host web apps on one Linode server. I can set up different web apps in Tomcat no problem but where do I tell what to send each web request to the right app on Tomcat?

At the moment I presume both domains will end up sending http requests to whatever server is listening to the 80/8080 ports and just return the default page for the server.

I've got as far as virtual hosts but I'm really looking for a bit of a leg up to save some time. Do I need to route the requests through Apache or do people manage the virtual hosting in Tomcat?

Thanks in advance.


Top
   
PostPosted: Sun Aug 05, 2012 1:50 pm 
Offline
Senior Member
User avatar

Joined: Thu Jul 12, 2012 3:55 pm
Posts: 133
Website: http://www.amitywebsolutions.co.uk
I have no experience with Tomcat but being a web developer and hosting provider for my customers, we use Virtualmin to manage all our web servers... we focus on web development not server administration, so Virtualmin will allow the whole shebang of virtual server, email accounts, FTP, SSH, etc all to be setup quickly using the admin interface. I dont think I would ever consider using the command line to setup all this for web hosting, would take too long. Unless you have some scripts to automate it.

_________________
Web Development Agency in South Wales


Top
   
PostPosted: Sun Aug 05, 2012 1:59 pm 
Offline
Senior Member

Joined: Sun May 23, 2010 1:57 pm
Posts: 315
Website: http://www.jebblue.net
TheRedAaron wrote:
I'be bought 2 domains and want both to host web apps on one Linode server. I can set up different web apps in Tomcat no problem but where do I tell what to send each web request to the right app on Tomcat?


Here's how I use Apache and Tomcat together on Ubuntu:

1) In /etc/apache2/conf.d I have two .conf files, one for http traffic and one for https. In the http one for example, I have <VirtualHost ipaddress:port> sections for each site I host in Tomcat or on whatever backend server I wanted like Ruby (that'll never happen).

2) In each of those <VirtualHost sections I don't use rule rewriting I'd just get myself into trouble so I do something very simple ... oh and I don't use that mod_jk connector either. I just do this ... for each site in its respective <VirtualHost section near the bottom of the section I put in two symbols (you need mod_proxy installed in Apache):

Code:
     # main site, I've had this set though I think Tomcat
     # works fine with it off, the default, depends on the needs
     # of the backend server
     ProxyPreserveHost On

     # main site, trailing slash is important in general
     ProxyPass        / http://127.0.0.1:8080/MyMainSite/
     ProxyPassReverse / http://127.0.0.1:8080/MyMainSite/
     # main site, one more thing I did but might not be
     # needed for the main site, can't remember why now
     ProxyPass        /MyMainSite http://127.0.0.1:8080/MyMainSite/
     ProxyPassReverse /MyMainSite http://127.0.0.1:8080/MyMainSite/

     # remaining sites just these two are needed
     # site FooTrain, trailing slash is important in general
     ProxyPass        / http://127.0.0.1:8080/FooTrain/
     ProxyPassReverse / http://127.0.0.1:8080/FooTrain/

     # site GlobalFoo, trailing slash is important in general
     ProxyPass        / http://127.0.0.1:8080/GlobalFoo/
     ProxyPassReverse / http://127.0.0.1:8080/GlobalFoo/


...etc.

One nice thing about this configuration is that one SSL certificate protects all the content for my main site whether the content comes from Tomcat or Apache or any other backend server that I choose to configure with a ProxyPass ProxyPassReverse combination.

Good luck!

PS I run Tomcat in its own account using a script:

Code:
# checktomcatrunning.sh
#!/bin/sh

wget --spider 127.0.0.1:8080
STATUS=$?
if [ "$STATUS" = "0" ]; then
  echo running
else
  echo stopped, restarting Tomcat
  # run the standard tomcat startup.sh
  /home/tomcataccountname/bin/runtomcat.sh
fi


And I run that checktomcatrunning.sh script from the account's cron:

Code:
* * * * * /home/tomcataccountname/bin/checktomcatrunning.sh >/dev/null 2>&1


Hope this helps.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group