[go: nahoru, domu]

Skip to content

Commit

Permalink
Add host information for reverse proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
30hours committed Feb 11, 2024
1 parent f2b9e91 commit 0e16141
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 0 deletions.
19 changes: 19 additions & 0 deletions host/README.md
Original file line number Diff line number Diff line change
@@ -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/<data>`. 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 <name>`. Otherwise the network configuration can be deleted.

**nginx.conf**

- Edit the `backend_ip` and `domain_name` variables in `nginx.conf`.
20 changes: 20 additions & 0 deletions host/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions host/html/error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
radar/down
58 changes: 58 additions & 0 deletions host/nginx.conf
Original file line number Diff line number Diff line change
@@ -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;
}

}
}

0 comments on commit 0e16141

Please sign in to comment.