aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCody Hiar <cody@hiar.ca>2023-05-05 10:52:26 -0600
committerCody Hiar <cody@hiar.ca>2023-05-05 10:52:26 -0600
commit396092d197fdd4af2af7671959667d2bd303de22 (patch)
tree8b95522122f8215c1ba41472fb7a3eae76c6f2c6
Initial commitHEADmaster
-rw-r--r--.gitignore12
-rw-r--r--Makefile19
-rw-r--r--README.md9
-rw-r--r--docker-compose.yml19
-rw-r--r--docker/Dockerfile1
-rw-r--r--docker/nginx/nginx.conf29
6 files changed, 89 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..696c85c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,12 @@
+.*.swp
+*.pyc
+*.pyo
+.DS_Store
+tags
+.ropeproject
+*.actual
+.vimcache
+.idea
+.mypy_cache
+.envrc
+*.sqlite
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..c954afa
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,19 @@
+.PHONY: build
+
+help:
+ @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
+
+build: ## Build the Docker image
+ docker-compose -p nginx-proxy-test build
+
+up: build ## Bring the container up
+ docker-compose -p nginx-proxy-test up -d
+
+down: ## Stop the container
+ docker-compose -p nginx-proxy-test stop
+
+enter: ## Enter the running container
+ docker-compose -p nginx-proxy-test exec mynginx /bin/bash
+
+clean: down ## Remove stoped containers
+ docker-compose -p nginx-proxy-test rm -f
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..c668776
--- /dev/null
+++ b/README.md
@@ -0,0 +1,9 @@
+# Nginx Proxy Test
+
+
+This repos sets up a docker compose environment with nginx as a reverse proxy
+to [httpbin]. This serves as a useful playground for testing nginx proxy rules
+locally for all kinds of different situtations.
+
+
+[1]: https://httpbin.org/
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..80ecbce
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,19 @@
+version: '3'
+services:
+ mynginx:
+ build:
+ context: ./
+ dockerfile: ./docker/Dockerfile
+ depends_on:
+ - httpbin
+ container_name: nginx-proxy-test
+ image: thornycrackers/nginx-proxy-test
+ ports:
+ - "8822:80"
+ volumes:
+ - .:/usr/src/app
+ - ./docker/nginx:/etc/nginx
+ httpbin:
+ image: kennethreitz/httpbin
+ ports:
+ - "8823:80"
diff --git a/docker/Dockerfile b/docker/Dockerfile
new file mode 100644
index 0000000..0616c4a
--- /dev/null
+++ b/docker/Dockerfile
@@ -0,0 +1 @@
+FROM nginx:1.23.4
diff --git a/docker/nginx/nginx.conf b/docker/nginx/nginx.conf
new file mode 100644
index 0000000..027d107
--- /dev/null
+++ b/docker/nginx/nginx.conf
@@ -0,0 +1,29 @@
+http {
+
+ upstream httpbin {
+ server httpbin:80;
+ }
+
+ server {
+ listen 80;
+
+ location / {
+ proxy_pass http://httpbin;
+ proxy_intercept_errors on;
+ }
+
+ # With the above "proxy_intercept_errors" option, this will capture any
+ # upstream 500/504 errors and return a 302 to a different url
+ error_page 500 504 /custom-errors.html;
+ location = /custom-errors.html {
+ return 302 http://127.0.0.1:8822/status/200;
+ }
+ }
+}
+
+events {
+ worker_connections 1024;
+}
+
+worker_rlimit_nofile 8192;
+