Browse Source

Initial commit

master
Matthew Raymer 5 months ago
commit
43334f4eae
  1. 1
      .env~
  2. 12
      docker-compose.yml
  3. 9
      survey-nginx/Dockerfile
  4. 3
      survey-nginx/html/hello_world.pl
  5. 13
      survey-nginx/html/index.html
  6. 6
      survey-nginx/log/web/access.log
  7. 4
      survey-nginx/log/web/error.log
  8. 34
      survey-nginx/nginx.conf
  9. 15
      survey-nginx/perl/MyModule.pm

1
.env~

@ -0,0 +1 @@
HAPPY_GREETING=Hello, from hackerbox.io :)

12
docker-compose.yml

@ -0,0 +1,12 @@
version: '3'
services:
survey-nginx:
container_name: survey-nginx
build:
context: ./survey-nginx
volumes:
- ./survey-nginx/html:/var/www
- ./survey-nginx/perl:/usr/share/perl
- ./survey-nginx/log/web:/var/log/nginx/web
ports:
- "8080:80"

9
survey-nginx/Dockerfile

@ -0,0 +1,9 @@
FROM nginx:1.27.0-alpine-perl
RUN apk update
RUN apk add bash curl
EXPOSE 80
ADD ./nginx.conf /etc/nginx/nginx.conf
RUN rm /etc/nginx/conf.d/default.conf

3
survey-nginx/html/hello_world.pl

@ -0,0 +1,3 @@
#!/usr/bin/perl -wT
print "Content-type: text/plain\n\n";
print "Hello World In CGI Perl"

13
survey-nginx/html/index.html

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<h1>Hello World In html file</h1>
</body>
</html>

6
survey-nginx/log/web/access.log

@ -0,0 +1,6 @@
127.0.0.1 - - [07/Jul/2024:09:25:01 +0000] "GET /hello_world.pl HTTP/1.1" 502 28 "-" "curl/8.5.0"
127.0.0.1 - - [07/Jul/2024:09:33:52 +0000] "GET /hello_world.pl HTTP/1.1" 502 28 "-" "curl/8.5.0"
127.0.0.1 - - [07/Jul/2024:09:41:42 +0000] "GET /hello_world.pl HTTP/1.1" 502 28 "-" "curl/8.5.0"
127.0.0.1 - - [07/Jul/2024:09:47:09 +0000] "GET /hello_world.pl HTTP/1.1" 502 28 "-" "curl/8.5.0"
127.0.0.1 - - [07/Jul/2024:09:51:26 +0000] "GET /hello_world.pl HTTP/1.1" 502 28 "-" "curl/8.5.0"
127.0.0.1 - - [07/Jul/2024:09:52:58 +0000] "GET /hello_world.pl HTTP/1.1" 502 28 "-" "curl/8.5.0"

4
survey-nginx/log/web/error.log

@ -0,0 +1,4 @@
2024/07/07 09:41:42 [info] 9#9: *1 client 127.0.0.1 closed keepalive connection
2024/07/07 09:47:09 [info] 26#26: *1 client 127.0.0.1 closed keepalive connection
2024/07/07 09:51:26 [info] 28#28: *3 client 127.0.0.1 closed keepalive connection
2024/07/07 09:52:58 [info] 45#45: *5 client 127.0.0.1 closed keepalive connection

34
survey-nginx/nginx.conf

@ -0,0 +1,34 @@
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log debug;
pid /var/run/nginx.pid;
load_module modules/ngx_http_perl_module.so;
events {
worker_connections 1024;
}
http {
perl_modules /usr/lib/perl5/vendor_perl;
include /etc/nginx/mime.types;
sendfile off;
server_tokens off;
server {
listen 80;
server_name _;
resolver 8.8.8.8;
location / {
perl 'sub {
my $r = shift;
$r->send_http_header("text/html");
$r->print("Hello from Perl embedded in nginx!\n");
return OK;
}';
}
location ~ \.pl$ {
# perl 'MyApp::handler'; # Assuming MyApp::handler is defined in a Perl module
}
}
}

15
survey-nginx/perl/MyModule.pm

@ -0,0 +1,15 @@
package MyModule;
use nginx; # Make sure to use the nginx module
sub handler {
my $r = shift; # Get the request object
$r->send_http_header("text/html"); # Send HTTP headers
# Print a simple HTML page
$r->print("<html><body><h1>Hello, Nginx Perl!</h1></body></html>");
return OK;
}
1; # Ensure the module returns true
Loading…
Cancel
Save