Proxying and routing URLs

his chapter describes how you can configure the proxy server to route URLs to different URLs or to different servers. This chapter also describes how to turn on proxying for specific resources

Enabling proxying for a resource

You can turn proxying on or off for all resources in a template. You can control whether proxying is on for the entire server, for various resources, or for resources as specified in a template file. This means you can deny access to one or more URLs by turning off proxying for that resource. This can be a global way to deny or allow all access to a resource. (You can also allow or deny access to resources by using URL filters.)

To enable proxying for a resource,

  1. In the Server Manager, click Routing|Enable, Disable.
  2. In the Editing drop-down list, choose the resource you want to configure.
  3. You can choose a default setting for the resource you specified: you can choose not to proxy that resource (disable proxying), or you can enable proxying of that resource.
  4. Click OK.

Routing URLs through another server

You can configure the way the proxy routes URLs. When the proxy server gets a request for a document, it can route the request to a different URL. For example, if the client tries to access http://some.company.com, you can configure the proxy to route the request to http://another.company.com.

When you route URLs, the proxy can let the client know that the URL is being rerouted. In Netscape Navigator, the location box can display the URL where the proxy retrieved the document. This means that if the client enters the URL http://some.company.com, when the proxy returns the document to the client, it can tell the client that the file really came from http://another.company.com.

If you don't want the proxy server to return the routed URL to the client, use the URL mapping feature, as discussed on page 76.

The following sections describe how to set up routing from one proxy server to another and from one proxy server to a SOCKS server.

Routing through another proxy

You can have the proxy access another proxy for some resources instead of accessing the remote server. This means you can chain proxies together. Chaining is a good way to organize several proxies behind a firewall. It also lets you build hierarchical caching.

For example, within an organization you can chain departmental proxies to a main proxy server, as shown in Figure 5.1. You can also set up several proxies in your organization so that each proxy server accesses and caches only specific files, such as one proxy that services HTTP requests and another that services FTP. Or, you might have one server that caches all files form the .com domain and another that caches all other files.

Chaining proxies together

To route URLs through another proxy,

  1. In the Server Manager, choose Routing|Routing.
  2. Select the template you want to use. You can choose to route all requests to the proxy server, but this isn't an efficient use of the proxy server.
  3. Choose the routing option you want.
  4. Click OK. Be sure to save and apply your changes.

Routing through a SOCKS server

You can configure the proxy to connect to a remote server using a SOCKS server for the selected resource. To use a SOCKS daemon to retrieve URLs matching the selected resource,

  1. In the Server Manager, choose Routing|Routing.
  2. Select the template you want to use. You can choose to route all requests to the proxy server, but this isn't an efficient use of the proxy server.
  3. Choose the routing option you want.
  4. Click OK. Be sure to save and apply your changes.

Sending the client's IP address to the server

Normally, the proxy server doesn't send the client's IP address to remote servers when making requests for documents. Instead, the proxy acts as the client and sends its IP address to the remote server. This is good protection if you don't want remote servers to know your internal IP addresses.

However, there are times when you might want to pass on the client's IP address:

To configure the proxy to send client IP addresses,

  1. In the Server Manager, choose Routing|Client IP Address Forwarding.
  2. Choose the template you want to use or choose the entire proxy server to always send the client's IP address.
  3. Select an option to turn on IP address forwarding. By default, the proxy server doesn't send IP addresses, but if you have several proxies in a chain and one proxy forwards the IP address to another, the subsequent proxy will also forward the IP address if its option is set to either default or enabled. Choose enabled to have the proxy server forward the client's IP addresses. Choose blocked to never forward the IP address.
  4. You can specify an HTTP header for the proxy to use when forwarding IP addresses. The normal HTTP header is named Client-ip, but you can send the IP address in any header you choose.
  5. Click OK. Be sure to save and apply your changes.

Disconnecting the proxy from the network

You can connect or disconnect the proxy server machine from the network. This makes it convenient to install the proxy on a portable machine that you can use for demonstrations.

When disconnected from the network, documents are returned directly from the cache--the proxy can't do up-to-date checks, so the documents are retrieved very quickly (the documents might not be up to date; see Chapter 7 for more information on caching).

Also, if you are not connected to a network, connections never hang because the proxy server is aware that there is no network and never tries to connect to a remote server. You can use this "no network" setting when the network is down, but the proxy server machine is running.

Note
Keep in mind that running the proxy disconnected from the network means that you will eventually be accessing stale data from the cache. Also, running without the network makes the proxy security features unnecessary.
The Netscape Proxy Server offers four network connectivity modes:

Default Mode is the same as Normal Mode.

Normal Mode is the normal operating mode for the proxy. The proxy retrieves documents from the content server if they are not already in the cache. If they are in the cache, they are checked against the content server to determine if they are up to date. If a cached file has changed, it is replaced with the current copy.

Fast-demo Mode is intended for giving smooth demonstrations. If a document is found in the cache, the content server is not contacted, not even to find out if the document has changed. This gets rid of any latency created by waiting for the content server to respond. If a document is not in the cache, it is retrieved from the content server and cached. The fast-demo mode has less latency than the normal mode, but can occasionally return stale data because once it has a copy of a document, it doesn't do up-to-date checks on it.

No-Network Mode is designed for portable machines during the time they are not connected to the network. The proxy returns the document if it is in the cache, or returns an error if it isn't. The proxy never tries to contact the content server, which prevents the proxy from hanging and timing out while trying to get a connection that doesn't exist.

To change the running mode for the proxy server,

  1. In the Server Manager, choose Routing|Connectivity Mode.
  2. Choose the template you want to use or choose to change the mode for the entire proxy server.
  3. Select the mode you want, and then click OK.
Be sure to save and apply your changes.

Changing the default FTP transfer mode

FTP has two different ways to establish a data connection between the FTP server and the client (the proxy acts as a client). The two modes are referred to as PASV (Passive) and PORT mode FTP.

Some FTP sites run a firewall, which makes PASV mode non-functional for proxy servers. Because of this, the proxy server can be configured to use the PORT mode FTP. You can turn on PASV mode for the entire server, or you can turn it on only for specific FTP servers.

Note
Even when PASV mode is on, the proxy server will use PORT mode if the remote FTP server doesn't support PASV mode.
If the proxy server is behind a firewall that makes the PORT mode FTP non-functional, you can't enable PORT mode. If default is selected for the template, the proxy server uses the mode from a more general template. If none is specified, PASV mode will be used.

Mapping URLs to other URLs

The Server Manager lets you map URLs to another server. This is sometimes called a "mirror" server. When a client accesses the proxy with a mirrored URL, the proxy gets the requests from the mirrored server and not from the server specified in the URL. The client is never aware that the request is going to a different server. You can also redirect URLs; in this case, the proxy returns only the redirected URL to the client (and not the document), so the client can then request the new document.

To map a URL to a mirror server, you specify a URL prefix and where to map it. The following sections describe the various types of URL mappings.

Creating a URL mapping

You can create four types of URL mappings:

Clients accessing a URL are sent to a different location on the same server or on a different server. This is useful when a resource has moved, or when you need to maintain the integrity of relative links when directories are accessed without a trailing slash.

For example, suppose you have a heavily-loaded web server called hi.load.com that you want mirrored to another server called mirror.load.com. For URLs that go to the hi.load.com computer, you can configure the proxy server to use the mirror.load.com computer.

The source URL prefix must be unescaped, but in the destination (mirror) URL, illegal characters must be escaped.

Warning!
Do not use trailing slashes in the prefixes!
To create a URL mapping,

  1. In the Server Manager, click URLs|Create Mappings.
  2. Choose the type of mapping you want to create.
  3. Type the URL prefix. For regular and reverse mappings, this should be the part of the URL you want to substitute. For regular expression mappings, this value should be a regular expression that for all the URLs you want to match. If you also choose a template for the mapping, the regular expression will only work for the URLs within the template's regular expression.

    For client autoconfiguration mappings, this value should be the full URL the client accesses.

  4. Type a map destination. For all mapping types except client autoconfiguration, this should be the full URL to map to. For client autoconfiguration, this value should be the absolute path to the .pac file on the proxy server's hard disk.
  5. Click OK to create the mapping.

Editing existing mappings

You can make changes to your existing mappings.

  1. Click URLs|View/Edit Mappings. The View, Edit, or Remove URL Mappings form appears.
  2. You can edit the prefix, the mapped URL, and template that are affected by the mapping.
  3. To remove a mapping, click the mapping you want to change, then click the link at the top of the form called Remove.
  4. Click OK to confirm your changes, or click Reset to undo them.

Redirecting URLs

You can configure the proxy server to return a redirected URL to the client instead of getting and returning the document. With redirection, the client is aware that the URL they originally requested has been redirected to a different URL. The client usually requests the redirected URL immediately. Netscape Navigator automatically request the redirected URL--the user doesn't have to explictly request the document a second time.

URL redirection is useful when you want to deny access to an area because you can redirect the user to a URL that explains why they were denied access.

To redirect one or more URLs,

  1. In the Server Manager, click URLs|Redirect.
  2. Type a URL prefix. This can be a complete URL or it can be a wildcard pattern.
  3. Type either a URL prefix or a fixed URL to map to.
  4. Click OK to create the mapping.