mirror of
https://github.com/30hours/blah2.git
synced 2024-11-18 12:33:58 +00:00
Add host information for reverse proxy
This commit is contained in:
parent
f2b9e912ac
commit
0e16141eda
4 changed files with 98 additions and 0 deletions
19
host/README.md
Normal file
19
host/README.md
Normal file
|
@ -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
host/docker-compose.yml
Normal file
20
host/docker-compose.yml
Normal file
|
@ -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
host/html/error.html
Normal file
1
host/html/error.html
Normal file
|
@ -0,0 +1 @@
|
||||||
|
radar/down
|
58
host/nginx.conf
Normal file
58
host/nginx.conf
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue