From a8a0ae5097b9eb7b7f17bd689a053fe876e88cc9 Mon Sep 17 00:00:00 2001 From: ICScaryThings Date: Sun, 29 May 2022 22:26:26 -0400 Subject: [PATCH] Add files to build a local testing nginx setup --- build_container.sh | 2 ++ nginx-test/Dockerfile | 3 +++ nginx-test/build_container.sh | 2 ++ nginx-test/default.conf | 50 +++++++++++++++++++++++++++++++++++ nginx-test/run_container.sh | 2 ++ 5 files changed, 59 insertions(+) create mode 100644 nginx-test/Dockerfile create mode 100755 nginx-test/build_container.sh create mode 100644 nginx-test/default.conf create mode 100755 nginx-test/run_container.sh diff --git a/build_container.sh b/build_container.sh index 7649a9b..2c22a7a 100755 --- a/build_container.sh +++ b/build_container.sh @@ -12,3 +12,5 @@ docker build -t $IMAGE_NAME . docker run --rm --name $CONTAINER_NAME -d $IMAGE_NAME docker cp ${CONTAINER_NAME}:${RESOURCES_SRC} ${RESOURCES_DST} docker stop $CONTAINER_NAME + +cp -r ${RESOURCES_DST} nginx-test/ diff --git a/nginx-test/Dockerfile b/nginx-test/Dockerfile new file mode 100644 index 0000000..22facf0 --- /dev/null +++ b/nginx-test/Dockerfile @@ -0,0 +1,3 @@ +FROM nginx +COPY default.conf /etc/nginx/conf.d/default.conf +COPY to-webserv/* /usr/local/share/treebird/ diff --git a/nginx-test/build_container.sh b/nginx-test/build_container.sh new file mode 100755 index 0000000..ec918bd --- /dev/null +++ b/nginx-test/build_container.sh @@ -0,0 +1,2 @@ +#!/bin/sh +docker build -t treebird-nginx-test . diff --git a/nginx-test/default.conf b/nginx-test/default.conf new file mode 100644 index 0000000..992cfec --- /dev/null +++ b/nginx-test/default.conf @@ -0,0 +1,50 @@ +server { + listen 80; + listen [::]:80; + server_name localhost; + + #access_log /var/log/nginx/host.access.log main; + location @treebird { + #include fastcgi_params; #Check your nginx installation for fastcgi.conf or fastcgi_param + 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 REQUEST_URI $request_uri; + fastcgi_param DOCUMENT_URI $document_uri; + fastcgi_param DOCUMENT_ROOT $document_root; + fastcgi_param SERVER_PROTOCOL $server_protocol; + fastcgi_param REQUEST_SCHEME $scheme; + fastcgi_param HTTPS $https if_not_empty; + + fastcgi_param GATEWAY_INTERFACE CGI/1.1; + fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; + + 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; + + fastcgi_param SCRIPT_FILENAME /usr/local/bin/treebird; # change this to the location of your treebird executable + fastcgi_param PATH_INFO $uri; + fastcgi_pass 127.0.0.1:4008; + } + + location / { + root /usr/local/share/treebird; #Change this to the location of the static files + try_files $uri @treebird; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + +} + diff --git a/nginx-test/run_container.sh b/nginx-test/run_container.sh new file mode 100755 index 0000000..7d9b181 --- /dev/null +++ b/nginx-test/run_container.sh @@ -0,0 +1,2 @@ +#!/bin/sh +docker run --rm --name nginx --network host treebird-nginx-test:latest