OctaGate Switch - The Smart HTTP Switchboard

OctaGate Switch
OctaGate Switch»
BUY NOW»
Downloads»
- 21+ Day FREE Trial»
Screenshots»
Requirements»
OctaGate Features»
- HTTP Load Balancing»
- HTTP Tunnel»
- Exchange with HTTPS»
- HTTPS Tunnel»
- HTTP Compression»
Demos»
Support & Documentation»
Contact us»
About OctaGate»
* OctaGate DNS»
* OctaGate MailStar»







Become an affiliate

Using OctaGate Switch with IntraWeb Apps

(This is only relevant when you're running IntraWeb Apps in stand alone mode - dlls are not effected by this)

Non Relative Paths

When you use OctaGate Switch to serve stand alone IntraWeb applications you will come across the problem that IntraWeb doesn't use relative paths for it's "/js/", "/cache/", "/Files/" and so on paths. If you want to place an IntraWeb application in a virtual path, you could create a virtual path for each of those paths so that OctaGate Switch knows that those paths should be sent to the IW app. But that would be very cumbersome, and it would mean that you could only have one IW app per domain. That's clearly not acceptable.

IntraWeb and URLBase

One way to solve this problem is to use the property called URLBase that is located on the TIWServerController. IntraWeb uses URLBase as a prefix to the previously mentioned paths, so that "/js" becomes URLBase + "/js". Setting URLBase to "/Booking" (note that there is no "/" at the end of the URLBase) would allow you to run a IW stand alone server on the path http://mysite/Booking/ .

 // Setting the URLBase
 
IWServerController.URLBase :='/Booking';

However, IntraWeb won't understand a request for "/Booking/js", because internally IW expects the path to simply be called "/js". Luckily, OctaGate Switch can perform URL rewriting before it passes the url on to IntraWeb.

OctaGate Switch must rewrite all incoming urls that match "/Booking*" as "/*", this is handled by a property called "Path Replace".

Virtual Path with Path Replace   

What you need to do in OctaGate Switch to handle IW apps in this fashion is to create a Virtual Path with the following settings;

  • Path = /Booking (no ending slash)
  • Target address = the machine that runs the IW app
  • Host Replace = '' (IW doesn't care about the host)
  • Path Replace = /
  • OutPort = the port that the IW app is listening to


        This is what the virtual path should look like

Changing the Path of the IW App

The downside to this is that we've compiled the IW app to ONLY ever answer on the "/Booking" path. If you want it to reply on a different path, you will have to change your code and re-compile. If you never expect to change the path, then that's not a problem. But if you expect to frequently change the path - or even expect to start several copies of the same IW app responding to different paths, then we need to set URLBase dynamically.

Luckily, OctaGate Switch sends a custom HTTP Header that can be used to set the URLBase. The header is called "OGPathRewrite" and contains Path + " "+ PathReplace. The value of Path is all we need to handle dynamical paths in an IW App, and the code below demonstrates how to do this in IW 7.0.14;


uses
  ... HTTPApp;

// Try to update URLBase or each request
procedure TIWServerController.
  IWServerControllerBaseBeforeDispatch(Sender: TObject; 
    Request: TWebRequest; Response: TWebResponse;
  var Handled: Boolean);
begin
  SetupOctaGateURLBase(self, Request);
end;

var
  OldOGPathRewrite  : string='';
procedure SetupOctaGateURLBase(IWServerController : 
  TIWServerControllerBase; Request: TWebRequest);
var
  OGPathRewrite, Base : string;
  p : integer;
begin
  // Find out if OG performed a path rewrite
  OGPathRewrite := Request.GetFieldByName('OGPathRewrite');

  // Only perform the work if a different rewrite has been
  // requested
  if (OGPathRewrite <> OldOGPathRewrite) then
  begin
    OldOGPathRewrite := OGPathRewrite;

    p := Pos(' ', OGPathRewrite);

    if p>0 then
    begin
      Base := Copy(OGPathRewrite, 1, p-1);

      // If the last char is a '/' we must drop it
      if Copy(Base, length(Base),1) = '/' then
        Base := Copy(Base, 1, Length(Base)-1);
    end else
      Base := '';

    if Base <> IWServerController.URLBase then
      IWServerController.URLBase := Base;
  end;//}
end;

We've created a Delphi unit for your convenience, that you can simply drop in and use that you can download here.


If you are using IntraWeb XI, then download this version.

   Contact Us  © 2010 OctaGate