diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6925f8e --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*/*.log +*/*.pid + +web/nginx.conf +web/*_temp/* \ No newline at end of file diff --git a/web/Makefile b/web/Makefile new file mode 100644 index 0000000..794ecae --- /dev/null +++ b/web/Makefile @@ -0,0 +1,16 @@ + +ROOT ?= $(PWD) +HTTP_PORT ?= 49228 + + +serve: nginx.conf + nginx -p $(ROOT)/ -c $(ROOT)/$< + + +nginx.conf: nginx.conf.in + cat $< | \ + sed -e 's@__ROOT__@$(ROOT)@g' \ + -e 's@__HTTP_PORT__@$(HTTP_PORT)@g' > $@ + + +.PHONY: serve diff --git a/web/fastcgi_params b/web/fastcgi_params new file mode 100644 index 0000000..d1862e9 --- /dev/null +++ b/web/fastcgi_params @@ -0,0 +1,19 @@ +fastcgi_param GATEWAY_INTERFACE CGI/1.1; +fastcgi_param SERVER_SOFTWARE nginx; +fastcgi_param QUERY_STRING $query_string; +fastcgi_param REQUEST_METHOD $request_method; +fastcgi_param CONTENT_TYPE $content_type; +fastcgi_param CONTENT_LENGTH $content_length; +fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; +fastcgi_param SCRIPT_NAME $fastcgi_script_name; +fastcgi_param REQUEST_URI $request_uri; +fastcgi_param DOCUMENT_URI $document_uri; +fastcgi_param DOCUMENT_ROOT $document_root; +fastcgi_param SERVER_PROTOCOL $server_protocol; +fastcgi_param REMOTE_ADDR $remote_addr; +fastcgi_param REMOTE_PORT $remote_port; +fastcgi_param SERVER_ADDR $server_addr; +fastcgi_param SERVER_PORT $server_port; +fastcgi_param SERVER_NAME $server_name; + +# vim:filetype=nginx diff --git a/web/lib/perl/base.pm b/web/lib/perl/base.pm new file mode 100644 index 0000000..48117e3 --- /dev/null +++ b/web/lib/perl/base.pm @@ -0,0 +1,20 @@ +package base; +use nginx; + + +sub handler { + my $r = shift; + $r->send_http_header("text/plain"); + return OK if $r->header_only; + + $r->print("hello!\n"); + $r->rflush; + + if (-f $r->filename or -d _) { + $r->print($r->uri, " exists!\n"); + } +} + + +1; +__END__ diff --git a/web/mime.types b/web/mime.types new file mode 100644 index 0000000..808160d --- /dev/null +++ b/web/mime.types @@ -0,0 +1,71 @@ + +types { + text/html html htm shtml; + text/css css; + text/xml xml rss; + image/gif gif; + image/jpeg jpeg jpg; + application/x-javascript js; + application/atom+xml atom; + + text/mathml mml; + text/plain txt; + text/vnd.sun.j2me.app-descriptor jad; + text/vnd.wap.wml wml; + text/x-component htc; + + image/png png; + image/tiff tif tiff; + image/vnd.wap.wbmp wbmp; + image/x-icon ico; + image/x-jng jng; + image/x-ms-bmp bmp; + image/svg+xml svg svgz; + + application/java-archive jar war ear; + application/mac-binhex40 hqx; + application/msword doc; + application/pdf pdf; + application/postscript ps eps ai; + application/rtf rtf; + application/vnd.ms-excel xls; + application/vnd.ms-powerpoint ppt; + application/vnd.wap.wmlc wmlc; + application/vnd.wap.xhtml+xml xhtml; + application/x-7z-compressed 7z; + application/x-cocoa cco; + application/x-java-archive-diff jardiff; + application/x-java-jnlp-file jnlp; + application/x-makeself run; + application/x-perl pl pm; + application/x-pilot prc pdb; + application/x-rar-compressed rar; + application/x-redhat-package-manager rpm; + application/x-sea sea; + application/x-shockwave-flash swf; + application/x-stuffit sit; + application/x-tcl tcl tk; + application/x-x509-ca-cert der pem crt; + application/x-xpinstall xpi; + application/zip zip; + + application/octet-stream bin exe dll; + application/octet-stream deb; + application/octet-stream dmg; + application/octet-stream eot; + application/octet-stream iso img; + application/octet-stream msi msp msm; + + audio/midi mid midi kar; + audio/mpeg mp3; + audio/x-realaudio ra; + + video/3gpp 3gpp 3gp; + video/mpeg mpeg mpg; + video/quicktime mov; + video/x-flv flv; + video/x-mng mng; + video/x-ms-asf asx asf; + video/x-ms-wmv wmv; + video/x-msvideo avi; +} diff --git a/web/nginx.conf.in b/web/nginx.conf.in new file mode 100644 index 0000000..eb51d86 --- /dev/null +++ b/web/nginx.conf.in @@ -0,0 +1,37 @@ +worker_processes 1; +error_log __ROOT__/error.log; +pid __ROOT__/server.pid; +daemon off; + + +events { + worker_connections 4096; +} + + +http { + include __ROOT__/mime.types; + + perl_modules __ROOT__/lib/perl; + include __ROOT__/perl_requirements.d/*; + + default_type application/octet-stream; + log_format main '$remote_addr - $remote_user [$time_local] $status ' + '"$request" $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + sendfile on; + tcp_nopush on; + autoindex on; + + server { + listen __HTTP_PORT__; + server_name localhost; + access_log __ROOT__/access.log main; + root __ROOT__/html; + + include __ROOT__/perl_locations.d/*; + } +} + + +# vim:filetype=nginx diff --git a/web/perl_locations.d/base.conf b/web/perl_locations.d/base.conf new file mode 100644 index 0000000..d0a74db --- /dev/null +++ b/web/perl_locations.d/base.conf @@ -0,0 +1,5 @@ +location / { + perl base::handler; +} + +# vim:filetype=nginx diff --git a/web/perl_requirements.d/base.conf b/web/perl_requirements.d/base.conf new file mode 100644 index 0000000..8d7663e --- /dev/null +++ b/web/perl_requirements.d/base.conf @@ -0,0 +1 @@ +perl_require base.pm;