|
|
HTTP ProxyThis component is a module that fits in with my Client / Server sample.
The idea is that once you've written your application server,
someone (usually a sales-dude) will ask you if it's possible
to access the information over the internet
(through a web server; a HTTP request).
So the grand picture is that you keep the server as it is - but modifies
the web server to transform incoming HTTP requests into the communication
protocol already defined and supported by your server.
Most web servers support some kind of extension API. With Microsoft Internet Information Server (IIS) it's the ISAPI module. The ISAPI moduleI've written an ISAPI extension, which intercepts requests to the web server. The request is embedded in the URL with which the client does a HTTP GET to the web server. Then the ISAPI module dismantles the request, turns it into messages to the application server through a normal IP connection and delivers the response back in the original HTTP request.The same stuff could actually have been implemented using a simple ASP page, but since this is a C++ sample, I'm writing it as an ISAPI module. The CodeThis source code is actually pretty simple. I used the MFC AppWizard to create an ISAPI module and simply included my general network wrapper classes to the project.The ISAPI module defines two URL commands: Get and Set. The commands are invoked simply by requesting the ISAPI DLL to run from a web request, like this:
The module catches the request, generate a response (as a HTML page) and sends
it back. It didn't have to be a HTML page, it could have been an XML document
or something nice, but for now it is a HTML page.
The MFC classes for writing ISAPI modules hides all the nasty stuff about
parsing URL arguments and generating HTML responses. This allows you to
quickly develop more complicated responses.
The latest version of Visual C++ even includes the same classes in a high-performance ATL version. The response page in this case either contains the requested value or an error code. The client must interpret this information by parsing the HTML content. Security and ScalabilityThere are two major advantages with building this seemingly complex system.SecurityThe added security comes from the fact that you do not place the application server on the web server.
The real security bonus comes when firewalls are added. Most companies have firewalls
in front of their web-server.
Some companies also have a firewall between the web-server and their local network.
The second firewall denies all access between the web server and the rest of the network
except for specific IP ports.
One such IP port would be the port the ISAPI module uses to communicate with
the application server.
ScalabilityOne obvious advantage is that the web-server is relieved from doing any processing locally. The web-server simply forwards the request to the application server.In fact, the web-server could forward requests to a pool of application servers. Having multiple application servers could scale the system tremendously if each application server needs to do any lengthy processing of each request. Source Code DependenciesMicrosoft Visual C++ 6.0Internet Information Server 5.0 Microsoft MFC Library Installation Guide
Download Files
Written by Bjarke Viksoe. Article submitted 9/29/2001. To the top
|
|||