feat: proxy local ftest instance to docker network

This commit is contained in:
Aravinth Manivannan 2023-09-28 22:54:04 +05:30
parent bd6afe2fd9
commit e434cf132d
Signed by: realaravinth
GPG key ID: F8F50389936984FF
4 changed files with 45 additions and 0 deletions

2
nginx/Dockerfile Normal file
View file

@ -0,0 +1,2 @@
FROM nginx
COPY ./nginx.conf /etc/nginx/conf.d/default.conf

20
nginx/docker-compose.yml Normal file
View file

@ -0,0 +1,20 @@
# SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
services:
ftest:
image: "forgeflux/ftest-nginx"
ports:
- 9080:80
container_name: ftest
extra_hosts:
- ftest-backend:host.docker.internal
networks:
- ftest
networks:
ftest:
name: ftest
external: true

9
nginx/init.sh Executable file
View file

@ -0,0 +1,9 @@
#!/bin/bash
docker run \
-d \
--name=ftest \
-p 9080:9000 \
--network=ftest \
--add-host ftest_backend:`/sbin/ip route|awk '/default/ { print $9}'`\
forgeflux/ftest-nginx

14
nginx/nginx.conf Normal file
View file

@ -0,0 +1,14 @@
server {
listen 9000;
server_name ftest default_server;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://ftest_backend:9000/;
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
}
}