Self-Referential (Redirection) URLs


Normally, web page developers do not use the complete web host name, directory, subdirectory, and file name (called the absolute path name) for every link they create within a website. Web developers like to use relative path names to files (so their code can easily be moved around in the directory structure if need be), and relative path names allow them to leave out the web host name when they create a link on a web page. This type of web page link is called a self-referential (or redirection) URL because the web developer wanted Apache to assume—if the web host name was not included in the link—the URL refers back to the current web host or web server.

IP-Based Virtual Hosts and Self-Referential URLs

With IP-based virtual hosts, the web host server name used in self-referential URLs is, by default, the value you give to the ServerName directive inside of the VirtualHost container. (Starting with version 2.0 of Apache, the ServerName directive can contain a fully qualified host name followed by an optional colon and port number.)

image from book
REVERSE DNS QUERIES AND SELF-REFERENTIAL URLS

If, for some reason, you do not want to set the ServerName directive inside of each IP-based VirtualHost container, you can leave it out and instead set the directive UseCanonicalName to dns. When you set UseCanonicalName to dns, Apache will figure out the ServerName to use in self-referential URLs by performing a reverse DNS query on the IP address specified in the VirtualHost container (the IP address the client used in the HTTP request). This IP address is sent to a DNS server to find out which host name it is associated with. This method will not resolve self-referential URLs on real servers in an LVS-NAT cluster because the IP address will be a RIP address (not a VIP address), and RIP addresses are not stored in DNS.[5] (To resolve self-referential URLs in an LVS-NAT cluster, specify the ServerName directive in the VirtualHost container, and set the directive UseCanonicalName to on.)

image from book

Name-Based Virtual Hosts and Self-Referential URLs

For name-based virtual hosts, the situation is different and much easier. As shown in the previous name-based virtual host example, the UseCanonicalName directive was set to off. This means self-referential URLs[6] are set to the host name sent by the client computer (embedded in their HTTP request). The same Apache configuration file can then be used on all of the cluster nodes inside an LVS-NAT cluster without modification, and the self-referential URLs will work properly.[7] (Again, note that with Apache version 2.0 and later, the value you give to the ServerName directive can be the fully qualified host name followed by a colon and a port number.)

[5]They can be stored in an internal naming service that the cluster nodes use to resolve IP addresses, though this is not normally done.

[6]And the CGI script variables SERVER_NAME and SERVER_PORT.

[7]In Chapter 14, we discuss persistence and explain how to configure your cluster so that self-referential URLs will even end up back on the same cluster node.



The Linux Enterprise Cluster. Build a Highly Available Cluster with Commodity Hardware and Free Software
Linux Enterprise Cluster: Build a Highly Available Cluster with Commodity Hardware and Free Software
ISBN: 1593270364
EAN: 2147483647
Year: 2003
Pages: 219
Authors: Karl Kopper

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net