[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cobalt-developers] change ip address problems
- Subject: Re: [cobalt-developers] change ip address problems
- From: "Robert G. Fisher" <rfisher@xxxxxxxxxxxxxxx>
- Date: Sat Aug 12 20:26:58 2000
On Sat, Aug 12, 2000 at 11:49:06AM -0700, Jeff Lasman wrote:
> Funny you should write this. Yesterday, I was talking to another
> list-member on the phone. I told him what I'd written (the paragraph
> double-quoted above) and I told him I fully expected someone to write
> back pretty much what you've written. I also hope someone will break
> down and explain it line by line; I really don't have the time to
> research everything; as I've said before I try not to answer posts from
> remembered knowledge; it's too easy to leave something out and make a
> mistake. I'd like to see the answer line by line on the list, written
> by a Cobalt rep, simply so beginners will understand it. And so in the
> future we can point to it definitively whenever the question arises (as
> it does every two or three days).
*shrug*, if someone wants something explained line by line
the docs handle this, not to mention it seems to me the
cobalt products are marketed to people who don't care to
know about the internals...
As you can see, most of this is explained in the httpd.conf
file already.
Anyway from the httpd.conf file of a RaQ2 here goes
( please note, I've substituded the actioal site name with
www.domain.com):
...
# ServerName allows you to set a host name which is sent back to clients for
# your server if it's different than the one the program would get (i.e. use
# "www" instead of the host's real name).
#
# Note: You cannot just invent host names and hope they work. The name you
# define here must be a valid DNS name for your host. If you don't understand
# this, ask your network administrator.
ServerName www.domain.com
# UseCanonicalName: (new for 1.3) With this setting turned on, whenever
# Apache needs to construct a self-referencing URL (a url that refers back
# to the server the response is coming from) it will use ServerName and
# Port to form a "canonical" name. With this setting off, Apache will
# use the hostname:port that the client supplied, when possible. This
# also affects SERVER_NAME and SERVER_PORT in CGIs.
UseCanonicalName on
# ( this is what I missed in my earlier comment on Server Name, as you
# can see from the above comments in the httpd.conf file, that this
# option turned on along with servername option will cause the server
# to rewrite what shows up in the location bar of a browser.
NameVirtualHost 10.24.1.4
<VirtualHost 10.24.1.4>
ServerName www.domain.com
ServerAdmin admin
DocumentRoot /home/sites/home/web
RewriteEngine on
RewriteCond %{HTTP_HOST} !^10.24.1.4(:80)?$
RewriteCond %{HTTP_HOST} !^www.domain.com(:80)?$
RewriteRule ^/(.*) http://www.domain.com/$1 [L,R]
RewriteOptions inherit
AliasMatch ^/~([^/]+)(/(.*))? /home/sites/home/users/$1/web/$3
AliasMatch ^/users/([^/]+)(/(.*))? /home/sites/home/users/$1/web/$3
</VirtualHost>
A sample for the "home" site. Again, note the use of ServerName
and remember UseCanonicalName is still 'on'. As for the Rewrite
stuff, this is essentially using a set of conditions specified
by the RewriteCond which specifies where to look in this case
the variables HTTP_HOST (what the user typed into the browser)
and the right hand side is the regular expression pattern
to check for. The RewriteRule takes the regular expression
on the left hand side and rewrites it to the expression on the
right.
In this case your comparing the HOST information against either
the IP or ServerName and optionally port 80, if this condition
is met then you are rewriting anything in the URI as the
ServerName/ServerURI -- simple.
Now from the srm.conf file:
RewriteEngine on
# Use the RewriteCond to strip the host away from the port
RewriteCond %{HTTP_HOST} ^([^:]+)
RewriteRule ^/admin/?$ http://%1:81/.cobalt/sysManage/index.html [L,R]
RewriteCond %{HTTP_HOST} ^([^:]+)
RewriteRule ^/siteadmin/?$ http://%1:81/.cobalt/siteManage/%1/index.html [L,R]
RewriteCond %{HTTP_HOST} ^([^:]+)
RewriteRule ^/personal/?$ http://%1:81/.cobalt/personal/index.html [L,R]
RewriteCond %{HTTP_HOST} ^([^:]+)
RewriteRule ^/.cobalt/(.+) http://%1:81/.cobalt/$1 [L,R]
RewriteCond %{HTTP_HOST} ^([^:]+)
RewriteRule ^/cgi-bin/.cobalt/(.+) http://%1:81/cgi-bin/.cobalt/$1 [L,R]
Now in this instance, the conditions to apply the rule are still
checks on the HTTP_HOST for well, in this case to simply make
sure this variable does not start with a colon.
The rules itself check for the /admin/, /siteadmin/, /personal/,
or /.cobalt/ and rewrites the request to port 81 (admin server)
from the HTTP_HOST value which is stored by the parenthesis and
the relevant link from there, %# is the ()'d matched name inthe
condition by position, $# is the ()'d matched item in the Rule.
again, this is very simple case of RTFM...a simple cross reference
of the comments in the file against the info in the documentation
for the appropriate modules only takes a few minutes.
--
Robert G. Fisher NEOCOM Microspecialists Inc.
System Administrator/Programmer (540) 666-9533 x 116