InformIT

Securing Web Applications through a Secure Reverse Proxy

Date: Jan 30, 2004

Article is provided courtesy of Prentice Hall Professional.

Return to the article

This article describes recommended practices for setting up the Sun ONE Proxy Server software to represent a secure content server to outside clients, preventing direct, unmonitored access to your server's data from outside your company. This article uses recommended practices to secure your web applications behind a firewall and leverage access and authentication using the Sun ONE platform products.

This article assumes an intermediate reader who is familiar with installing and configuring the Sun ONE Proxy Server. It also assumes that the reader can configure the firewall router to allow a specific server on a specific port access through the firewall without allowing any other machines in or out.

In today's complicated, heterogeneous back-end environments, organizations search for ways to manage their diverse corporate infrastructure. One way to accomplish this task is to centralize all Web resource requests to multiple back-end systems. With the large volume of different web servers available, all with multiple versions, updates, and platforms, it is very easy to become vunerable to attacks. For example, different versions of web servers used by companies today have security alerts issue to the public that describe these problems and how to exploit them

Placing the web servers behind the firewall and denying access to them greatly reduces their vulnerability to attacks. The actual web server is accessed using reverse proxy servers. The reverse proxy server retrieves the Web resources through the firewall from the actual web server. In addition, the data returned from the actual web server can be cached locally at the reverse proxy level to improve the access time of the web site. Having a firewall working in tandem with a reverse proxy server greatly reduces the vulnerabilities.

This article covers the following topics:

This article is intended for use by intermediate-level system administrators. It assumes that you are familiar with installing and configuring the Sun™ ONE Proxy Server software. It also assumes that you understand network filtering and can properly configure your firewall. This article describes basic capabilities that are found in many common proxy implementations. As such, this approach is not limited to the Sun™ ONE implementation although the examples in this article are.

This article describes recommended practices for installing and configuring the Sun ONE Proxy Server software for the purpose of constructing a secure-content gateway that prevents direct, unrestricted, and unmonitored access to your company's internal systems and data from outside clients. The article also provides recommended practices to secure your web applications behind a firewall and leverage access and authentication with the Sun ONE platform products. In this article, security is accomplished two ways:

This article assumes that the reader has taken the necessary measures to ensure that the suggested recommended practices are built on a secure platform.

Understanding the Reverse Proxy Server

A reverse proxy server is a server that acts as a broker between two entities, validating and processing a transaction in such a way that the actual parties to the transaction do not directly communicate with one another. This means that the proxy acts on behalf of the content web server. A reverse proxy server can represent one or several content servers. Random servers cannot be accessed through a reverse proxy server. Only the predetermined set of files that are available from the content server can be accessed. A reverse proxy server is a designated proxy server for those servers, and it is used by all clients for access to the specific site that it is servicing.

Having a firewall working in tandem with a reverse proxy server can greatly reduce the possibility of exposing your back-end data resources. The firewall must be configured to only allow specific types of access (HTTP/HTTPS) from the reverse proxy server to the back-end web servers. This configuration ensures that requests coming from the proxy are valid requests and all other requests are seen as potential hackers. A properly configured firewall will accept requests from the proxy server and route it appropriately to your back-end resources.

One of the biggest benefits of having a reverse proxy configuration is that your clients have a single point of access to your content web servers. This obviously adds a second layer of security that allows you to track and contain an attack against your content servers. The second benefit is that you, as a system administrator, have a single point of control over who can access the servers and what content you allow the users to access. Another great benefit is that outsiders are not aware of the names of the content servers you are proxying. This allows you to easily replace content servers or make host name changes since the rules or "mappings" are handled by the reverse proxy. This does not affect outside clients. The idea of setting up an architecture with a single point of access helps in the load balancing and failover. For companies concerned with hardware costs, leveraging a reverse proxy can significantly lower hardware cost because it eliminates the need to have separate hardware and software for internal and external users. Internal and external users can access the same servers using the same HTTP requests. This method also eliminates the need to have different hardware to store data for internal and external users. The reverse proxy is capable of securing the back-end data that is required to service an HTTP application without exposing any information to outside world.

So, what exactly does a reverse proxy do? When a client makes a request to your web site, the request goes to the proxy server. The proxy server then sends the client's request through a specific path in the firewall back to the content web server. The content web server passes the result through the path back to the proxy. The proxy sends the retrieved information to the client, as if the proxy were the actual content server (see Figure 1).

Figure 1FIGURE 1 Reverse Proxy Deployed at Firewall

If the content web server returns an error message, the proxy server can intercept the message and change any URLs listed in the headers before sending the message to the client. This prevents external clients from getting redirection URLs to the internal content server.

Since a reverse proxy server potentially allows access to internal hosts, disabling generic (forward) proxying on the proxy server, or applying appropriate access controls if they are enabled, is important. The firewall should be configured so that it allows connections from the reverse proxy to the content web servers exclusively, and not to any other internal resources. The proxy server's configuration should not allow generic proxy requests. It should only allow reverse proxy requests and remap them appropriately to the content web servers.

In addition, the reverse proxy can be configured to secure data utilizing Secure Socket Layers (SSL). This type of configuration is known as a secure reverse proxy. A secure reverse proxy can provide an encrypted connection from a proxy server outside a firewall to a secure content server inside the firewall. It also allows clients to connect securely to the proxy server, facilitating the secure transmission of information (such as credit card numbers).

A reverse proxy configuration has specific components. These components and their functions are:

Setting Up the Proxy Server

In this example, the installation parameters for the Sun ONE Proxy Server are:

Server root : /opt/SunONE/proxy
Machine name: myproxy.sun.com
SuiteSpot user: proxyadmin
SuiteSpot group: sunone
Are you using an LDAP-based directory server? N
Administration port: 81
Run administration server as: proxyadmin
Server administrator ID: proxyadmin
Password: sun1ProxySvr

NOTE

The server must have restricted access to your system resources. Therefore, you should set up and run the proxy with a non-privileged system user account. The server will run with the UNIX_ user account you specify during installation. Any child processes of the proxy and all files created by the proxy are created with this account as the owner.

To Set up the Secure Proxy Server

  1. Open a browser and go to http://myproxy.sun.com:81.

  2. You will be prompted for a user ID and password. Enter the user ID proxyadmin and the password selected during the installation (for example, sun1ProxySvr).

    NOTE

    Refer to the administration guide to start up your Administration Server.

  3. Click the Create New iPlanet Web Proxy Server 3.6 link.

  4. The web proxy server starts the installation wizard. Do the following:

    1. Create a new proxy instance:

    2. Server Name: myproxy.sun.com
      Bind Address: <ip_address_of_server>
      Server Port: 80
      Server Identifier: myproxy
      Server User: proxyadmin
      Processes: 32
      
      Select: Attempt to resolve IP addresses only for access 
           control.
      Select: Extended log format (includes all byte counts, 
           transfer time).
      Enable Proxying of: HTTP and HTTPS
      Enable SSL Tunneling for: HTTPS
      Uncheck: Cache FTP
      Uncheck: Cache Gopher

      Leave all other options set to the default values.

      Leave all other options set to the default values.

    3. Click OK.

    4. The wizard now creates the new proxy instance.

    5. Click Return to Server.

  5. Select the newly created proxy instance.

  6. Select the URLs button from the server menu.

  7. Remove the default Client autoconfig mappings.

    1. Click Remove in the Administration Interface.

    2. The proxy will request verification that you want to remove that entry.

    3. Click OK to complete the process.

    4. Click Save and Apply.

    5. This will ensure that the changes are recognized by the proxy server and restart the proxy instance to ensure that the changes take effect immediately

  8. Click Create Mappings in the Administration Interface to create Regular URL mappings.

  9. To illustrate the configuration in FIGURE 1, the reverse proxy server at http://myproxy.sun.com will be configured to proxy the content web server at http://www.sun.com.

    Note that the reverse proxy server address is the advertised address, and users can access it without any knowledge of the main server.

    NOTE

    Since the proxy server software can support both forward and reverse proxy modes at the same time, the forward proxy may be used when performing requests intended for the reverse proxy server to keep the request from making an unnecessary loop from the forward to reverse proxy.

    1. Select Regular for Mapping type.

    2. Enter the following for Map Source Prefix:

    3. http://myproxy.sun.com
    4. Enter the following for Map Destination:

    5. http://www.sun.com
    6. Click OK.

    7. Click Save and Apply.

    8. This will ensure that the changes are recognized by the proxy server and restart the proxy instance to ensure that the changes take effect immediately.

  10. Create Reverse URL mappings.

    1. Click Create Mappings in the Administration Interface.

    2. Select Reverse for Mapping type.

    3. Enter the following for Map Source Prefix:

    4. http://www.sun.com
    5. Enter the following for Map Destination:

    6. http://myproxy.sun.com
    7. Click OK.

    8. Click Save and Apply.

    9. This will ensure that the changes are recognized by the proxy server and restart the proxy instance to ensure that the changes take effect immediately.

  11. Verify Reverse Proxy configuration by opening a browser and accessing the proxy server.

  12. In this example, enter:

    http://myproxy.sun.com

Understanding the Secure Reverse Proxy

Secure reverse proxying occurs when one or more of the connections between the proxy server and another machine uses the Secure Sockets Layer protocol to encrypt data.

Secure reverse proxying has many uses, for example:

Secure reverse proxying causes each secure connection to be slower due to the overhead involved in encrypting your data. However, because SSL provides a caching mechanism, two connecting parties can reuse previously negotiated security parameters, dramatically reducing the overhead on subsequent connections.

This scenario is effective if there is little or no chance that the information being exchanged between your proxy and content server can be accessed by unauthorized users (FIGURE 2). If your company requires a higher level of security, the proxy server can communicate securely with the back-end Web Server over SSL. Another alternative is to choose technologies such as IP Security Protocol (IPSec).

Figure 2FIGURE 2 Secure Reverse Proxy

To Set Up a Secure Reverse Proxy Server Instance

  1. Open a browser and go to http://myproxy.sun.com:81.

  2. You will be prompted for a user ID and password. Enter the user ID proxyadmin and the password selected during the installation (for example, sun1ProxySvr).

  3. Click the Create New iPlanet Web Proxy Server 3.6 link. The web proxy server starts the installation wizard. Do the following:

    1. Create a new Proxy instance:

    2. Server Name: myproxy.sun.com
      Bind Address: ip_address_of_server
      Server Port: 443
      Server Identifier: secure-myproxy
      Server User: proxyadmin
      Processes: 32
      Select: Attempt to resolve IP addresses only for access 
           control.
      Select: Extended log format (includes all byte counts, 
           transfer time).
      Enable Proxying of: HTTP and HTTPS
      Enable SSL Tunneling for: HTTPS
      Uncheck: Cache FTP
      Uncheck: Cache Gopher

      Leave all other options set to the default values.

    3. Click OK.

    4. The wizard creates the new proxy instance.

    5. Click Return to server selector.

  4. Generate your server's key pair (public and private keys).

  5. To generate a key-pair file, you need to run the key-pair file generator program from the command line.

    1. Log in as the proxy user.

    2. Run the key-pair file generation program by typing $PROXY_HOME/bin/admin/admin/bin/sec-key.

    3. When prompted, type an alias for the new key-pair file.

    4. Multiple instances can use different key pairs so you mightwant to choose an alias that matches your server (for example, myproxy). This way, you can easily identify the appropriate key pair to use for each specific instance. The alias cannot contain spaces, but it can use symbols that your operating system allows in file names (such as underscores). By default, the key-pair file is stored in server_root/alias/alias-key.db, where alias is the alias you typed. If you used the alias myproxy, your key-pair file would be server_root/alias/myproxy-key.db.

    5. A screen with a progress meter appears. Type random keys at different speeds until the progress meter is full.

    6. The time between each of your keystrokes is used to generate a random number for the unique key-pair file.

    7. When prompted, type a password of eight characters or more for your key-pair file.

    8. The password must have at least one non-alphabetical character (a number or punctuation mark). Make sure you memorize this password. The security of your server is only as good as the security of the key-pair file and its password. In this example, password is set to sun1ProxySvr.

      You must know the password for the key-pair file referenced by the alias—this is the password you must enter before starting or stopping a server that uses SSL encryption. The server uses the password to get your private key from the key pair.

  6. Request a certificate from a certificate authority (CA).

    1. Click the Keys & Certificates button from the Administration Interface.

    2. Click Request Certificate from the left menu options.

    3. Supply the appropriate information:

    4. Select: New Certificate
      Select: CA Email Address: <your_email_address>
      Alias: select_your_alias (that is, myproxy)
      Key Pair File Password: your_password (that is, sun1ProxySvr)
      Requestor Name: Your_Full_Name
      Telephone Number: Your_Telephone_Number
      Common Name: Fully qualified host name (that is, myproxy.sun.com)
      Email Address: your_email_address
      Organization: official name of your company
      Organizational Unit: optional organization within company
      Locality: optional entry describing your city
      State or Province: full name of state (that is, California)
      Country: two-character abbreviation (that is, US)

      NOTE

      We suggest that you specify your email in the "CA Email Address" field so that you can review the certificate request prior to submitting it to the Certificate Authority.

    5. Click OK.

    6. The wizard creates the certificate request.

      ----BEGIN NEW CERTIFICATE REQUEST-----
        MIIB1TCCAT4CAQAwgZQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlh
       MRQwEgYDVQQHEwtTYW50YSBDbGFyYTEeMBwGA1UEChMVU3VuIE1pY3Jvc3lzdGVt 
       cyBJbmMuMRQwEgYDVQQLEwtTdW4gT05FIFBUUzEkMCIGA1UEAxMbZ3Jhc3Nob3Bw 
       ZXIucmVkLmlwbGFuZXQuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDI 
       +/4yIe1mJBHDQLy8sTtbAAaP6yy300pYj3t/i8diOsj/YCtYIJatWzkuoFgOQ+1K 
       hiD+diS+HlYTh0ki/q8hCIFm/e08BnhXQ+zhMdwtazDWGeNqqKR9P1A6+WZIVtxa 
       QWkdsXrYUkAkpKh+O8BsIpgBTelQQMbCetvhuI2oWwIDAQABoAAwDQYJKoZIhvcN 
       AQEEBQADgYEAoAo/iQlu7CByZpWauXjDCfy9/W6jSKxXvxWQf+A22DNZ/LszgCf9 
       uwPAyr8E9RS2HUGCUtoBgWhzynCM3kS4qZnaGKM4EuIY7tGq5xkj7epVA0PI7O5G 
       Pc5b2qs5NJOGVcvewZCOYtDQ1eaH4W5gZlHfu7PtG/CgH1Li5thKLTU= 
       
      -----END NEW CERTIFICATE REQUEST----- 
    7. Submit the generated certificate request to your CA.

    8. Remember that this capability can be provided internally by your organization, or this request can be fulfilled by organizations such as Verisign or Thawte.

  7. Install the certificate the CA sends to you.

    1. Click the Keys & Certificates button in the Administration Interface.

    2. Click Install Certificate from the left menu options.

    3. Supply the appropriate information:

    4. Certificate for: This server
      Select: Message Text (with headers):
      <PASTE THE CERTIFICATE>
      Select: alias from the drop-down list (that is, myproxy)
      Encryption: On
      Port Number: (default SSL port is 443)
    5. Click OK.

  8. Install the Trusted CA's certificate.

    1. Click the Keys & Certificates button in the Administration Interface.

    2. Click Install Certificate from the left menu options.

    3. Supply the appropriate information:

    4. Certificate for: Trusted Certificate Authority (CA)
      Certificate Name: My Trusted CA
      Select: Message Text (with headers):
      Select: alias from the drop-down list (that is, myproxy)
    5. Click OK.

  9. Activate SSL for your server.

  10. NOTE

    For instructions on how to select and disable "weak" ciphers, refer to the "Increase Server Security" section in the Sun ONE Web Proxy Server 3.6 SP3 Administrator's Guide.

    1. Click the secure proxy instance that was created.

    2. Click Encryption On/Off in the menu.

    3. Supply the appropriate information:

    4. Certificate for: This server
      Select: Message Text (with headers):
      <PASTE THE CERTIFICATE>
      Select: alias from the drop-down list (that is, myproxy)
    5. Click OK.

    6. Click Save and Apply.

    7. The server will apply the changes and try to restart itself. Since the server is not in SSL mode, it will need to read the key-pair password. Since you have not supplied it, the server will not start.

    8. Select On/Off from the menu.

    9. Click On to start your secure reverse proxy.

    10. When prompted, enter your key-pair password., that is, sun1ProxySvr.

To Set Up URL Mappings

  1. Select the URLs button in the server menu.

  2. Remove the default Client autoconfig mappings:

    1. Click Remove in the Administration Interface.

    2. The proxy will request verification that you want to remove that entry.

    3. Click OK.

    4. Click Save and Apply.

    5. This will ensure that the changes are recognized by the proxy server and restart the proxy instance to ensure that the changes take effect immediately.

  3. Create Regular URL mappings.

  4. To illustrate the configuration with the example in FIGURE 2, the reverse proxy server at:

    https://myproxy.sun.com

    will be configured to proxy the content web server at:

    http://www.sun.com

    Note that the reverse proxy server address is the advertised address, and users may access it without any knowledge of the main server.

    1. Click Create Mappings in the Administration Interface.

    2. Select Regular for Mapping type.

    3. Enter the following for Map Source Prefix:

    4. https://myproxy.sun.com
    5. Enter the following for Map Destination:

    6. http://www.sun.com
    7. Click OK.

    8. Click Save and Apply.

    9. This will ensure that the changes are recognized by the proxy server and restart the proxy instance to ensure that the changes take effect immediately.

  5. Verify Reverse Proxy configuration.

  6. Open a browser and access the proxy server. In this example, enter:

    http://myproxy.sun.com

Controlling Access with Client Certificates

Since you have enabled SSL on your server, you can use client certificates in conjunction with access control. The server gathers information from the client certificate and matches it with a user entry in a Lightweight Directory Access Protocol (LDAP) directory. This match ensures that the client has a certificate and an entry in the LDAP directory. It can also ensure that the client certificate matches the one in the LDAP directory. Servers can use client certificates to ensure authenticity when communicating with a client. They can also use the certificate to determine if a user has access to the server. For a server to do this, you must specify that a resource requires a client certificate to access it. When users attempt to access a restricted resource, their client sends the server the client certificate, which the server checks against its list of mappings. If the certificate belongs to a user to whom you have granted access to the resource, the resource is served.

To leverage this function, you must first configure your directory services. The directory services tell the proxy server where to look for user and group data that you want to use to secure access to the proxy.

The following example uses the Sun ONE™ Directory Server to facilitate this function. This article assumes that you can configure and administer the Sun ONE Directory Server to have access through the firewall.

NOTE

The system administrator should be familiar with installing and configuring a Directory Server. To facilitate the SSL Client Certificate authentication, this configuration is required.

Currently, the proxy server does not support secured directory server access (LDAP over SSL).

To Set Up the Directory Services

This example leverages the Sun ONE Directory Server.

  1. Open a browser and go to http://myproxy.sun.com:81.

  2. You will be prompted for a user ID and password. Enter the user ID proxyadmin and the password selected during the installation (for example, sun1ProxySvr).

  3. Click the Global Settings link in the menu.

  4. In the left panel, click the Configure Directory Service link.

  5. Select the LDAP Directory Server by supplying the appropriate information:

  6. Host Name: myldap.sun.com
    Port: 389
    Use SSL for secure connections?: no
    Base DN: o=sun.com
    Bind DN: cn=directory manager
    Bind Password: sun1ProxySvr

    NOTE

    This bind DN is used only to initially search for the user name you entered in the administration server authentication dialog box. Once the entry corresponding to this user name is located, the administration server rebinds to the directory server using the retrieved entry. Therefore, if the user name you supplied when you first logged in to the administration server does not have access to the directory server, you will not have any access to the directory server, regardless of the bind DN information provided in this field.

  7. Click Save Changes.

To Set Up Users in the Directory Server

  1. Open a browser and go to http://myproxy.sun.com:81.

  2. You will be prompted for a user ID and password. Enter the user ID proxyadmin and the password selected during the installation (for example, sun1ProxySvr).

  3. Click the Users and Groups link in the menu.

  4. From the left panel, click the New User link.

  5. Supply the appropriate information:

  6. Given Name (First Name): Proxyadmin
    Surname (Last Name): Administrator
    Full Name: Proxy Administrator
    User id: proxyadmin
    Password: sun1ProxySvr
    Password (Again): sun1ProxySvr
    Email Address: proxy@sun.com
    Add New User to: o=sun.com
  7. Click Save Changes.

Configuring the Proxy Server to Handle Client Authentication with Digital Certificates

The certificate mapping file determines how a server should look up a user entry in the LDAP directory. You edit this file and add entries to match the organization of your LDAP directory and to list the certificates you want your users to have. This is achieved with the certmap.conf file. This file, located at server_root/userdb, can be edited and entries added to match the organization of your LDAP directory and to list the certificates you want your users to have.

Specifically, the mapping file defines:

The following example configures the certmap.conf file so the Proxy Server can begin its search in the LDAP tree.

  1. Modify the cert.map.conf file.

  2. Refer to the notes in the file for references to the proper configuration.

  3. To enable the feature, modify the magnus.conf file.

  4. The magnus.conf file is located in server/root/proxy-<\instance/config. A variable with two possible values (ON/OFF) has been added. This feature is disabled (OFF) by default. Use the following syntax:

  5. CertificateChecking ON

To Restrict Access

  1. Open a browser and go to http://myproxy.sun.com:81.

  2. You will be prompted for a user ID and password. Enter the user ID proxyadmin and the password selected during the installation (for example, sun1ProxySvr).

  3. Select the Secure-Reverse Proxy instance.

  4. Click the Restrict Access link in the menu.

  5. Select Entire Server from the drop-down box.

  6. Turn access control off or on for the entire server by clicking either Turn off access control or Turn on access control.

  7. Turning on access control causes more access control settings to appear on your screen.

    For both Read and Write access, set the default access to Allow or Deny.

    NOTE

    Read access allows a user only to view the file. Write access allows the user to change or delete the file, assuming the user also has access to the file through your server computer's operating system. (Technically, Read includes these HTTP methods: GET, HEAD, POST, and INDEX. Write includes PUT, DELETE, MKDIR, RMDIR, and MOVE.)

  8. Specify which users are the exceptions to the default access for each access type by clicking the appropriate Permissions button.

  9. For this example, the permissions are set to Deny for both Read and Write access.

    1. Click the Permissions button for Read access.

      1. Supply the appropriate information:

      2. Users: proxyadmin
        Authentication Method: Client certificate (SSL)

        Leave all other options set to the default values.

      3. Click Done.

      4. Click OK in the main restrict access window.

      5. Click Save and Apply.

      6. This will ensure that the changes are recognized by the Proxy Server and restart the proxy instance to ensure that the changes take effect immediately.

    2. Verify Reverse Proxy configuration via SSL authentication using client certificates.

      1. Open a browser and access the proxy server. In this example, enter:

      2. https://myproxy.sun.com

        The proxy will request a client certificate from the browser. Provide the certificate that you requested from the certificate server that contains the UID used in the example and the proxy will allow access to the resource.

      For other aspects of security tuning for the Sun ONE Proxy Server such as setting banners, caching size/configuration, denial of service (DoS) considerations and so forth, refer to "Increase Server Security" section in the Sun ONE Web Proxy Server 3.6 SP3 Administrator's Guide.

    About the Author

    Anh-Duy Nguyen is a member of the Sun ONE Product Technical Support (PTS) organization in Santa Clara, California. He is a member of the team responsible for providing back-line technical support for the Sun ONE products. Currently, he focuses on the Sun™ ONE Web Server and Sun ONE Proxy Server products.

    Prior to joining Sun, Anh-Duy was consulting with Netscape and focusing on e-commerce deployments.

    References

    Ordering Sun Documents

    The SunDocsSM program provides more than 250 manuals from Sun Microsystems, Inc. If you live in the United States, Canada, Europe, or Japan, you can purchase documentation sets or individual manuals through this program.

    Accessing Sun Documentation Online

    The docs.sun.com web site enables you to access Sun technical documentation online. You can browse the docs.sun.com archive or search for a specific book title or subject. The URL is http://docs.sun.com/. To reference Sun BluePrints™ OnLine articles, visit the Sun BluePrints OnLine Web site at:

    http://www.sun.com/blueprints/online.html.

800 East 96th Street, Indianapolis, Indiana 46240