very strange things going on with parked domains

Diatone

Well-Known Member
Aug 22, 2001
109
0
316
Ok,

http://www.curbdiver.com - Works fine
http://curbdiver.com - Works fine
http://www.curbdiver.net - A parked Domain ontop of Curbdiver.com - Displays a Apache 404 not found error on the .jsp page
http://curbdiver.net - The same parked domain - Displays a TOMCAT 404 error page.

The site is a JSP site. So can anyone clue me in on why the parked domain is screwing up, and not loading the JSP page correctly?

Thanks
 

jsteel

Well-Known Member
Jul 4, 2002
646
0
166
Atlanta, GA
You need to Install Servlets for every second-level domain, i.e.

1) curbdriver.com
2) curbdriver.net

Tomcat performs it's mappings based on domain names, not IP addresses, etc. We personally stay away from adding JSP/Servlet support for every parked domain and tell everyone to create a simple index.html page that does nothing but a redirect to the index.jsp on the primary domain. This way you don't have to add JSP/Servlet support to the parked domains. Everytime you add JSP/Servlet support to a domain, including parked domains, it uses additional system resources.

Jaz
 

Diatone

Well-Known Member
Aug 22, 2001
109
0
316
Ok, Thanks for replying... Couple things.. When I try to install JSP servlets through WHM on an account, it only gives me the option to install it on the main curbdiver.com account. Not the parked domains.

Second, how would someone go about setting up an index.html page to redirect the the main domain from a parked domain? There isn't even folders for seperate webfiles on parked domains..

Thanks
 

jsteel

Well-Known Member
Jul 4, 2002
646
0
166
Atlanta, GA
1) It takes manual modification of the httpd.conf file.

2) Assuming the customer's main page for their site is index.jsp, simply create an index.html file and define a script that uses the settimeout function (to about 10ms) with a window.location equal to http://www.domain.com/index.jsp. I would post the code, but the forum will strip it out anyway as it views the javascript as a potential hack.

Then anyone that enters either domain.com or domain.net will get redirected to the index.jsp page on domain.com without the need to add JSP/Servlet support to the .net domain and in turn using more of your server's resources.

Jaz

[quote:05b6395f17][i:05b6395f17]Originally posted by Diatone[/i:05b6395f17]

Ok, Thanks for replying... Couple things.. When I try to install JSP servlets through WHM on an account, it only gives me the option to install it on the main curbdiver.com account. Not the parked domains.

Second, how would someone go about setting up an index.html page to redirect the the main domain from a parked domain? There isn't even folders for seperate webfiles on parked domains..

Thanks[/quote:05b6395f17]
 

mikelegg

Well-Known Member
Mar 29, 2005
330
3
166
To get .jsp working on a parked domain (assuming that it's already working on the primary domain) all you have to do is -

1. Copy the existing hosts configuration found in /usr/local/jakarta/tomcat/conf/server.xml so that there are 2 identical nodes in the file.

Then modify the new node and change the "name" value from the primary domain name to the parked domain name. (Leave the appBase value the same)

2. Restart Tomcat
 

FeeL

Well-Known Member
Apr 17, 2004
134
2
168
Rio de janeiro
cPanel Access Level
Reseller Owner
minor bug?

Hi there,

Can this be seen as a Minor Bug in Cpanel?

I think they should think in a way to fix this!
 

Azraell

Member
Aug 2, 2006
21
0
151
Brasil / Rio de Janeiro
gentomcat3

#!/usr/bin/perl
# cpanel4 - scripts Copyright(c) 1997-2002 cPanel, Inc..
# All rights Reserved.
# [email protected] http://cpanel.net
# This code is subject to the cpanel license. Unauthorized copying is prohibited
print "Scanning httpd.conf.";

BEGIN { push(@INC,"/scripts"); }

use SafeFile;

my(%USERS);
open(UD,"/etc/userdomains");

while(<UD>) {
s/[\s\n\r]*//g;
my($domain,$user) = split(/:/, $_);
$USERS{$domain} = $user;
}
close(UD);

my $httpconf = find_httpconf();

open(HTTPDCONF, "$httpconf");
$xu = 0;

#BEGIN_GAMBI
%alias = ();
$vh = 0;
$DBG = 0;

LINE: while (<HTTPDCONF>){
#s/\>//g; #Guarda a posicao no <file>
#comment - GoTo :-p
next LINE if( (/^#/) or (/^$/) );

print $DBG ? "\n\n DEBUG(line): " . $_ : '';

#Inicio do VirtualHost
if (/\<virtualhost (\S+)($|\s)/i) {
print ".";
$mvh = $1;
$vh = 1;
$xu++;
}
#Dentro do VirtualHost
if ($vh == 1){
if (/^jkmount/i) { $JK{$xu} = 1; }
if (/^WebApp/i) { $JK{$xu} = 1; }
if (/servername (\S+)($|\s)/i){
#print ".";
$sn = $1;
$SN{$xu} = $1;
}

#BEGIN_GAMBI
#Nao posso comparar com o ServerName pois pode vir antes ou depois no <file>
if (/serveralias\s+(\S+)\s+www/i){ #(www\S+)/i){ #\.$1/i){
print $DBG ? "\n DEBUG(alias): " . $1 . " ($2) ($sn)" : '';

#Dah algum bug louco q nao acha depois a key no hash
$holder = $sn; #$holder =~ s/^www\.//;

if ($alias{$holder}){ push( @{$alias{$holder}}, $1 ); }
else{ $alias{$holder} = [$1]; } #$alias{$sn} = $holder;
}
#END_GAMBI
if (/documentroot (\S+)/i) {
#print "X";
$DR{$xu} = $1;
}
#Fim do VirtualHost
if (/\<\/virtualhost(\S+)($|\s)/i) {
print ".";
$vh = 0;
}
}#END_if(vh)_

print $DBG ? "\t" . "DEBUG(vh): " . $vh : '';

}

close(HTTPDCONF);
print "\n";

#BEGIN_GAMBI_DEBUG
if ($DBG){
for (sort keys %alias){
print "\n\nKey: " . $_ . "";
@list = @{$alias{$_}};

for $i (@list){ print "\n\t" . $i; }
}
}
#END_GAMBI

foreach $server (sort keys %JK) {
$s1 = $SN{$server};
$s2 = $s1;
$s2 =~ s/^www\.//g;
next if ($s2 eq "" || $s1 eq "");

if ($DR{$server} ne "") {
$nhosts{$s1} = $DR{$server};
}
if ("$s2" ne "$s1") {
$nhosts{$s2} = $DR{$server};
}
}

#BEGIN_GAMBI_DEBUG
#aqui vao ser mostrados somente alguns itens q estan no %dic, somente os q tem entrada de JSP (JkMount, etc)
if ($DBG){
for (keys %nhosts){
$_ =~ s/^www\.//; #$s2 = "www." . $_;

print $DBG ? "\nKEY: $_" : "";

if( $alias{$_} or $alias{"www." . $_} ){ print "\n\nITEM: $_"; }
}
}

#END_GAMBI


foreach my $nhost (sort keys %nhosts) {
my $docbase = $nhosts{$nhost};
my $tdoc = $docbase;
$tdoc =~ s/public_html\/$//g;
$tdoc =~ s/public_html$//g;
$tdoc .= "webapps";
if (-d $tdoc) {
$docbase = $tdoc;
}

$entries = $entries . <<EOM;
<Host name="$nhost" appBase="$docbase">
EOM

#BEGIN_GAMBI
$holder = $nhost; @list = (); $switch = 0; $w3 = 0;
$holder =~ s/^www\.//;

#Essa parte tah feia, mas devido ao bug medonho lah de cima, eu to com preguica de consertar
if ($alias{$holder}) { $switch = 1; }
elsif ($alias{"www." . $holder}) { $holder = "www." . $holder; $switch = 1; }

if ($switch){
@list = @{$alias{$holder}};

for ($i = 0; $i <= $#list; $i++){
$entries = $entries . "\t <Alias>" . $list[$i] . "</Alias>\n";

#Preguica, entao vai um lazy hack aqui
$alias{$holder}[$i] = "www." . $alias{$holder}[$i];

}
}
#END_GAMBI

$entries = $entries . <<EOM;
<Context path="" reloadable="true" docBase="$docbase" debug="1"/>
<Context path="/manager" debug="0" privileged="true"
docBase="/usr/local/jakarta/tomcat/server/webapps/manager">
</Context>
</Host>
EOM

if ($USERS{$nhost} ne "") {

if (my $pid = fork()) {
#master
} else {
setuids($USERS{$nhost});
if (! -e "${docbase}/WEB-INF") {
mkdir("${docbase}/WEB-INF",0755);
}
if (! -e "${docbase}/WEB-INF/classes") {
mkdir("${docbase}/WEB-INF/classes",0755);
}
if (! -e "${docbase}/WEB-INF/lib") {
mkdir("${docbase}/WEB-INF/lib",0755);
}
if (! -e "${docbase}/WEB-INF/classes/ServletsTestPage.class" &&
-e "/usr/local/jakarta/tomcat/samples/ServletsTestPage.class") {
system("cp","-f","/usr/local/jakarta/tomcat/samples/ServletsTestPage.class",
"${docbase}/WEB-INF/classes/ServletsTestPage.class");
}
if (! -e "${docbase}/jsptest.jsp" &&
-e "/usr/local/jakarta/tomcat/samples/jsptest.jsp") {
system("cp","-f","/usr/local/jakarta/tomcat/samples/jsptest.jsp",
"${docbase}/jsptest.jsp");
}
exit();
}

}
}

my(@SO);
my $inhost = 0;
my $lasthost = 0;
my $line = 1;
my $solock = SafeFile::safeopen(\*SO,"+<","/usr/local/jakarta/tomcat/conf/server.xml");
while(<SO>) {
if ( ! $inhost && /<Host/ ) {
$inhost = 1;
}
if ( $inhost && /<\/Host/) {
if ( ! $lasthost ) {
$lasthost = $line;
$line++;
push(@SO,$_);
}
if ( $lasthost ) {
$inhost = 0;
next;
}
}
if ( $lasthost && ! $inhost ) {
$line++;
push(@SO,$_);
} elsif ( $inhost && ! $lasthost ) {
$line++;
push(@SO,$_);
} elsif ( ! $inhost && ! $lasthost ) {
$line++;
push(@SO,$_);
}
}
seek(SO,0,0);
$line = 0;
foreach (@SO) {
$line++;
if ( $line == ($lasthost + 1) ) {
print SO $entries;
}
print SO;
}
truncate(SO,tell(SO));
SafeFile::safeclose(\*SO,$solock);

system("/usr/sbin/stoptomcat");
system("/usr/sbin/starttomcat");

sub find_httpconf {
my(@LOC,$loc);
@LOC = ("/usr/local/apache/conf/httpd.conf",
"/etc/httpd/conf/httpd.conf");
foreach $loc (@LOC) {
if (-e $loc) { return $loc; }
}
return "";
}

sub setuids {
my($user) = $_[0];
my($uid,$gid);
(undef,undef,$uid,$gid) = getpwnam($user);
if ( ! ($( = int($gid)) ) {
print "error setting gid\n";
exit;
}

if ( ! ($) = "$gid $gid") ) {
print "error setting gid\n";
exit;
}
if (! (($< = $uid) && ($> = $uid)) ) {
die "error setting uid ($uid) [$user]\n";
}
return $uid;
}
 
Last edited: