doing perl web stuff with nginx
This commit is contained in:
parent
70b5f7b160
commit
50c240b0e1
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
*/*.log
|
||||||
|
*/*.pid
|
||||||
|
|
||||||
|
web/nginx.conf
|
||||||
|
web/*_temp/*
|
16
web/Makefile
Normal file
16
web/Makefile
Normal file
@ -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
|
19
web/fastcgi_params
Normal file
19
web/fastcgi_params
Normal file
@ -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
|
20
web/lib/perl/base.pm
Normal file
20
web/lib/perl/base.pm
Normal file
@ -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__
|
71
web/mime.types
Normal file
71
web/mime.types
Normal file
@ -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;
|
||||||
|
}
|
37
web/nginx.conf.in
Normal file
37
web/nginx.conf.in
Normal file
@ -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
|
5
web/perl_locations.d/base.conf
Normal file
5
web/perl_locations.d/base.conf
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
location / {
|
||||||
|
perl base::handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
# vim:filetype=nginx
|
1
web/perl_requirements.d/base.conf
Normal file
1
web/perl_requirements.d/base.conf
Normal file
@ -0,0 +1 @@
|
|||||||
|
perl_require base.pm;
|
Loading…
Reference in New Issue
Block a user