This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.
To: "'ModPerl List'" <modperl@apache.org> From: "Andy Sharp" <asharp@nector.com> Subject: RE: Multiple Sites Date: Mon, 3 Dec 2001 22:36:30 -0700 >From the start o' the thread: > "But if I put in URL/directory and a forward slash/ > eg. http://URL/directory/ then it shows the default.htm page. But I know my > customers, and they will not put in the directory forward slash. How do I > get around this issue?" This isn't really a mod_perl issue, it's common to all of apache. Even though this isn't in the scope of the list, here's your problem and answer. When you request a file from the apache web server. "URL/something" and something doesn't exist AND a directory exists under the same name, httpd sends the client a redirect to SERVER_NAME/something/ thus removing the need for people to type the trailing slash. (the server figured out if you need it, and adds it if neccesary, magic eh?) What you need to do is ensure that the ServerName directive in httpd.conf is indeed resolvable, because that's what the client's going to be looking for whenever httpd needs to redirect the client to itself. Sometimes people use the IP address (ugy imho), typically I use the domainname without the www, just because I hate typing. As others have aluded to, if you're trying to serve multiple domains (or hostnames) off one IP, you use a system called software virtual hosting. HTTP/1.1 Supports the Host: field in the http header to resolve to the site domain. Here's the config for the truly lazy (at least it worked for me) NameVirtualHost IP.address.goes.here <VirtualHost IP.address.goes.here> ServerAdmin .... DocumentRoot .... ServerName This is the part that's causing the redirect problem above ErrorLog .... CustomLog ... ErrorDocument ... ... Aliases .... ... ProxyPasses .... ... Any other config oddities ... </VirtualHost> Of course all of this is in the httpd guide http://httpd.apache.org/docs/ Search @ http://search.apache.org/docs/ === To: "Purcell, Scott" <spurcell@ltcgroup.com>, <modperl@apache.org> From: "Tim Tompkins" <timt@arttoday.com> Subject: Re: Multiple Sites Date: Tue, 4 Dec 2001 11:15:23 -0700 "Purcell, Scott" <spurcell@ltcgroup.com> wrote: > I have the need to create 10 web sites off my > Apache web server. I do not want to use 10 IP > addresses. So I am doing to cheeze and do a > URL/directory/index.html foreach site. > Then I would give each customer a URL of URL/directory and > I would like the index.html or the default.html to come > up. But it does not. > I edited my conf file to this > <IfModule mod_dir.c> > # DirectoryIndex index.html > DirectoryIndex default.htm > > </IfModule> > But but it does not work. But if I put in URL/directory and > a forward slash/ eg. http://URL/directory/ then it shows the > default.htm page. But I know my customers, and they will not > put in the directory forward slash. How do I get around this > issue? === To: "'ModPerl List'" <modperl@apache.org> From: Joe Brenner <doom@kzsu.stanford.edu> Subject: [OT] Re: Multiple Sites Date: Wed, 05 Dec 2001 18:52:06 -0800 "Andy Sharp" <asharp@nector.com> wrote: > As others have aluded to, if you're trying to serve > multiple domains (or hostnames) off one IP, you use a > system called software virtual hosting. HTTP/1.1 Supports > the Host: field in the http header to resolve to the site > domain. There's a limitation on virtual hosts though, if you want to do any kind of ecommerce stuff with SSL (which works via the IP number), it won't work if you try to do it with more than one of the vhosts. So you're clients are going to be stuck using an external agency (like paypal?) if they want to take on-line payments. (Though, it's always seemed to me that it might be a decent design to have *one* vhost dedicated to accepting payments for the other vhosts... so when the user is ready to close the deal they get kicked to "payment.super_secure.com" where they're asked for the credit card info to finish processing). It rather sounds to me that you have a TransHandler that needs some polishing. The translation handler should inspect for the resolved path being a directory. If it is a directory and the requested uri is lacking a trailing forward slash then it needs to issue a redirect with the trailing slash as mod_dir would have done. If the resolved path is a directory and the uri includes the trailing forward slash, then you'll need to resolve the index file. It is possible, however, to run some preliminary translation on the uri -- pulling out and noting interesting things from the uri -- and then DECLINE the request to allow Apache's translations to finish resolving the request to a file. Here's an example of this: package My::Apache::TransHandler; use strict; use Apache::Constants qw(:response); sub handler { my $r = shift; # Assuming a pipe delimited list of virtual directories # set these in httpd.conf like this: # PerlSetVar VirtualDirectories "dir1|dir2|dir3|dir4" my $virtual_dirs = $r->dir_config('VirtualDirectories'); if ( $r->uri =~ m!^/($virtual_dirs)$!o ) { # virtual directory only, no trailing slash $r->header_out( Location => $r->uri . "/" ); return REDIRECT; } # see if the uri contains the prefix if ( $r->uri =~ m!^/($virtual_dirs)/(.*)!o ) { # save the virtual path in $r->notes $r->notes('VIRTUAL_PATH' => $1); # reset the uri to everything following the virtual directory # you may want to change this in some other way $r->uri( "/$2" ); } # if you want apache to finish resolving the uri to a file... return DECLINED; # otherwise, add code to resolve to the file } 1; NOTE: I've not tested the above code, so it could contain errors. === To: "'ModPerl List'" <modperl@apache.org> From: Joe Brenner <doom@kzsu.stanford.edu> Subject: [OT] Re: Multiple Sites Date: Wed, 05 Dec 2001 18:52:06 -0800 "Andy Sharp" <asharp@nector.com> wrote: > As others have aluded to, if you're trying to serve > multiple domains (or hostnames) off one IP, you use a > system called software virtual hosting. HTTP/1.1 Supports > the Host: field in the http header to resolve to the site > domain. There's a limitation on virtual hosts though, if you want to do any kind of ecommerce stuff with SSL (which works via the IP number), it won't work if you try to do it with more than one of the vhosts. So you're clients are going to be stuck using an external agency (like paypal?) if they want to take on-line payments. (Though, it's always seemed to me that it might be a decent design to have *one* vhost dedicated to accepting payments for the other vhosts... so when the user is ready to close the deal they get kicked to "payment.super_secure.com" where they're asked for the credit card info to finish processing). === To: "'ModPerl List'" <modperl@apache.org> From: ___cliff rayman___ <cliff@genwax.com> Subject: Re: [OT] Re: Multiple Sites Date: Wed, 05 Dec 2001 19:01:31 -0800 > (Though, it's always seemed to me that it might be a decent > design to have *one* vhost dedicated to accepting payments > > for the other vhosts... so when the user is ready to close > the deal they get kicked to "payment.super_secure.com" where > they're asked for the credit card info to finish > processing). i have seen it done this way before. just got to make sure you can identify the client since you will not get back a cookie for your vhost. you will probably have to reset the cookie for the domain of your isp, or pass as hidden data, or in the url. http://www.mydomain.com/buystuffnow.html https://www.isp.com/~mydomain.com/paymenow.html?sessionID=xyz987123456 === To: mod_perl list <modperl@apache.org> From: Wim Kerkhoff <wim@merilus.com> Subject: Re: [OT] Re: Multiple Sites Date: Wed, 05 Dec 2001 19:27:55 -0800 Joe Brenner wrote: > > "Andy Sharp" <asharp@nector.com> wrote: > > > As others have aluded to, if you're trying to serve > > multiple domains (or hostnames) off one IP, you use a > > system called software virtual hosting. HTTP/1.1 Supports > > the Host: field in the http header to resolve to the site > > domain. > > There's a limitation on virtual hosts though, if you want to > do any kind of ecommerce stuff with SSL (which works via the > IP number), it won't work if you try to do it with more than > one of the vhosts. Yeah, I've scratched my head on that issue before. Eventually I gave up after reading the mod_ssl docs: http://www.modssl.org/docs/2.8/ssl_faq.html#vhosts The most common way to do it is to use IP aliasing to assign multiple IPs to your server, once for each SSL vhost. I just did a search through the apache-modssl mailing list, and you can actually do multiple unique SSL name-based vhosts on the same IP, _if_ use use separate ports for each. That might be acceptable as well... ie domain1.com is accessed via https://domain1.com:1000, domain2.com is https://domain2.com:1001, etc. http://marc.theaimsgroup.com/?l=apache-modssl&w=2&r=1&s=ssl+virtual+host+name+based&q=b ===