Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
nginx javascript module
C JavaScript Shell

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
html
js
src
.gitignore
README
config
config.make
load_urls.txt
nginx-file-rename.txt
nginx.conf
request-body-file.txt
run-tests

README

Some features:
* nearly full port of ngx_http_perl_module functionality
* support for native Nginx subrequests that calls passed JS callback with the response body
* cosy headers management (via Nginx.HeadersIn and Nginx.HeaderOut classes)
* environment variables handling with the code taken from Mozilla's js interpreter
* and working require() function that finds js-files walking through JSLIB env variable (like RUBYLIB and PERL5LIB)
* initial support for files via Nginx.File (rename, create/delete)

The code uses ngx_assert() and ngx_log_debug() almost everywhere, so the debugging must not be a pain.


CONFIGURE

The JS module could be compiled as any other nginx module:
./configure --add-module=/absolute/path/to/the/ngx_http_js_module/

If you want to look into the guts please configure like the following:
HTTP_JS_COLOR=yes ./configure --with-debug --add-module=/absolute/path/to/the/ngx_http_js_module/

--with-debug enables the JS module debug logging in addition to the nginx builtin;
HTTP_JS_COLOR=yes enables the colored logging for the JS module.


MAKE

Then run make as you usual do.

After make processe has successfuly completed you may run some simple tests for JS module (before the actual installation) with this:
make test-js

This will run nginx on 19090 port and process some requests to it with curl.

If you get the following error:
.../objs/nginx: error while loading shared libraries: libmozjs.so: cannot open shared object file: No such file or directory

please, try to set LD_LIBRARY_PATH env variable like so:
export LD_LIBRARY_PATH="/usr/local/lib/"
and then run make test-js again.



INSTALL

Then you may peacefully run:
make install
Something went wrong with that request. Please try again.