diff --git a/host/README.md b/host/README.md new file mode 100644 index 0000000..7964de7 --- /dev/null +++ b/host/README.md @@ -0,0 +1,19 @@ +# blah2 Host + +A reverse proxy to host blah2 on the internet. + +## Description + +This can be used to forward the radar to the internet. The radar front-end is at `localhost:49152`, and the API is located at `localhost:3000/api/`. This reverse proxy forwards `localhost:49152` to a port of your choosing, and forwards `localhost:3000` to the same port at `/api/`. + +## Usage + +**docker-compose.yml** + +- Change the output port from `8080` as desired in `docker-compose.yml`. +- The environment variable `VIRTUAL_HOST=domain.tld` is only applicable if also using [jwilder/nginx](https://github.com/nginx-proxy/nginx-proxy). +- If using [jwilder/nginx](https://github.com/nginx-proxy/nginx-proxy), ensure both containers are on the same network with `sudo docker network create `. Otherwise the network configuration can be deleted. + +**nginx.conf** + +- Edit the `backend_ip` and `domain_name` variables in `nginx.conf`. \ No newline at end of file diff --git a/host/docker-compose.yml b/host/docker-compose.yml new file mode 100644 index 0000000..2be23f1 --- /dev/null +++ b/host/docker-compose.yml @@ -0,0 +1,20 @@ +version: '3' + +networks: + nginx-web: + external: true + +services: + httpd: + restart: always + image: nginx:1.25.2-alpine + ports: + - 8080:80 + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf + - ./html:/usr/local/apache2/htdocs + environment: + - VIRTUAL_HOST=domain.tld + networks: + - nginx-web + container_name: blah2 \ No newline at end of file diff --git a/host/html/error.html b/host/html/error.html new file mode 100644 index 0000000..8ae485e --- /dev/null +++ b/host/html/error.html @@ -0,0 +1 @@ +radar/down \ No newline at end of file diff --git a/host/nginx.conf b/host/nginx.conf new file mode 100644 index 0000000..eec5fbd --- /dev/null +++ b/host/nginx.conf @@ -0,0 +1,58 @@ +user nginx; +worker_processes auto; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + default_type application/octet-stream; + include /etc/nginx/mime.types; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + keepalive_timeout 65; + + include /etc/nginx/conf.d/*.conf; + + server { + listen 80 default_server; + listen [::]:80 default_server; + include /etc/nginx/mime.types; + + set $backend_ip localhost; + set $domain_name localhost; + + proxy_pass_header Content-Type; + proxy_set_header X-Real-IP $domain_name; + proxy_set_header X-Forwarded-For $domain_name; + proxy_set_header Host $domain_name; + proxy_http_version 1.1; + proxy_set_header Connection ""; + proxy_connect_timeout 1; + proxy_next_upstream error timeout http_500 http_502 http_503 http_504 http_404; + proxy_intercept_errors on; + + location / { + proxy_pass http://$backend_ip:49152; + } + + location ~ ^/(maxhold|api|stash)/(.*) { + proxy_pass http://$backend_ip:3000/$1/$2; + } + + error_page 501 502 503 504 =200 /error.html; + location = /error.html { + root /usr/local/apache2/htdocs; + } + + } +}