Nirvana Javascript : Serving From Another Webserver

The Nirvana JavaScript API consists of three files:

  • lib/nirvana.js
  • lib/distrib/index.html
  • lib/distrib/nClient.js

Nirvana Realm Servers provide the option of exposing an HTTP web server interface for serving files to clients, removing the need to install a third party web server for hosting applications. Of course, it is possible to use a third party web server to host applications too.

Here we will explain how to deploy applications in both scenarios.

Web Applications on a Realm File Plugin

Your application source code, and the Nirvana lib directory and its contents, need to be deployed to directory on the Realm Server, and a File Plugin configured to provide access to this directory.

Let us assume that the Nirvana lib directory is accessible via the file plugin at some path, say: /js/nirvana/lib.

To use Nirvana, applications then simply need to include nirvana.js as follows:

<script src="/js/nirvana/lib/nirvana.js"></script>

Your NirvanaSession can be started with a relatively simple configuration, as follows:

NirvanaSession.start({
        applicationName	: "myExampleApplication",
        sessionName 	: "myExampleSession",
        username 	: "testuser"
});

Web Applications on a Third Party Web Server

Your application source code, and the Nirvana lib directory and its contents, are deployed to a third party web server, such as Apache.

In addition, another copy of the Nirvana lib directory and its contents need to be deployed to a directory on the Realm Server, and a File Plugin configured to provide access to this directory.

The third party web server must be running in the same DNS domain, using the same protocol (i.e. http or https) as the Nirvana Realm interface file plugin, and running on the same port.

Let us assume that the Nirvana lib directory is accessible via the file plugin at some path, say: /js/nirvana/lib.

Finally, we'll assume that the Nirvana lib directory is accessible on the third party web server at some path, say: /front/end/server/lib.

To use Nirvana:

  1. Applications need to include nirvana.js as follows:

    <script src="/front/end/server/lib/nirvana.js"></script>
    
  2. The NirvanaSession.start() call must use a configuration object that includes the following three key/value pairs:

    • realmHosts : An array of Non-FQDN hostnames of the realm servers in use, e.g. [ "nirvana", "nirvana2" ]
    • libPath : Absolute URL Path to lib directory on Realm Server's File Plugin, e.g. "/js/nirvana/lib"
    • domain : The DNS domain shared by your Realm Server and third party web server, e.g. "mycompany.com"
  3. The InitJavascript value set on the Realm Server should have the following value (replace mycompany.com with the appropriate domain):

    <script>document.domain = "mycompany.com";</script>

  4. Your NirvanaSession can then be started with a configuration such as:

    NirvanaSession.start({
            applicationName	: "myExampleApplication",
            sessionName 	: "myExampleSession",
            username 	: "testuser",
            domain 	 	: "mycompany.com",
            realmHosts 	: [ "nirvana" ], 	// name of realm host
            libPath 	: "/js/nirvana/lib" 	// path to lib on realm host file plugin
    });
    

For more information, please see Nirvana Sessions in JavaScript, which describes in more detail the options that can be passed into the NirvanaSession configuration object.