Skip to content
This repository

Embedding SpiderMonkey into nginx

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 html global root with an index page April 27, 2010
Octocat-spinner-32 js
Octocat-spinner-32 src
Octocat-spinner-32 .gitignore ignore temps and logs April 27, 2010
Octocat-spinner-32 README
Octocat-spinner-32 config
Octocat-spinner-32 config.make test-js now depends on build May 08, 2010
Octocat-spinner-32 load_urls.txt http_load urls December 05, 2009
Octocat-spinner-32 nginx-file-rename.txt working File.rename() April 30, 2010
Octocat-spinner-32 nginx.conf
Octocat-spinner-32 padding.txt larger padding May 16, 2010
Octocat-spinner-32 request-body-file.txt use HTTP 1.0 to avoid Expect: 100-Continue April 28, 2010
Octocat-spinner-32 run-tests
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.


This module requires the SpiderMonkey to be properly installed in your system. We plan to make SpiderMonkey sources a part of the module tree to provide the latest mozjs version right with the module.


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:
HTTP_JS_COLOR=yes enables the colored logging for the JS module.


Then run make as you usual do.

After the make process has successfully 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 issue some requests to it with curl.

If you get the following error:
.../objs/nginx: error while loading shared libraries: 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.


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