NGINX V8 Module


From Docunext Technology Wiki

Jump to: navigation, search

Contents

Summary

I'm seeing more and more server side javascript modules. Very interesting. This module uses the V8 Javascript engine from Google to power dynamic with Javascript. I'm compiling it now.

Compiling

	objs/ngx_modules.o \
	-L/var/www/dev/nodows/work/packages/v8 -lv8 -lstdc++ -lcrypt -lWand -lpcre -lssl -lcrypto -lz -lxml2 -lxslt -lexslt
/var/www/dev/nodows/work/packages/v8/libv8.a(platform-linux.o): In function `v8::internal::LinuxSemaphore::Wait(int)':
platform-linux.cc:(.text._ZN2v88internal14LinuxSemaphore4WaitEi+0x1a): undefined reference to `clock_gettime

I think that's because I built V8 static, I'm building shared now. That wasn't it, I had to add "-lrt" to the config file.

Configuration

        location = /t/jsv8 {
            v8 /tmp/simple.js;
        }

Example File

This is provided at the ngxv8 site:

function process(request, response) {
    if (request.userAgent.indexOf('iPhone OS 2') != -1) {
        response.write('This is iPhone OS 2');
    } else {
        response.contentType = 'text/xml; charset=utf-8';
        response.write('<?xml version="1.0" encoding="utf-8"?><ngxv8/>');
    }
    return 200;
}

Questions

  • Does AJAX work? I don't think its possible without an http client.
  • How useful is a javascript environment without access to a browser dom?
  • Is there a way to make the javascript file reload without having to reload the server?


See Also

Links

Personal tools