Authgear has an internal endpoint that can authenticate HTTP request.
Prerequisite
You must follow this to get Authgear running first!
Create a simple application server
Below is a very simple application server written in Python that echoes most of the request headers.
from wsgiref.simple_server import make_server
def header_name(key):
parts = key.split("_")[1:]
parts = [part.lower() for part in parts]
return "-".join(parts)
def app(environ, start_response):
status = '200 OK'
headers = [('Content-type', 'text/plain; charset=utf-8')]
start_response(status, headers)
for key, value in environ.items():
if key.startswith("HTTP_"):
name = header_name(key)
yield ("%s: %s\n" % (name, value)).encode()
with make_server('', 8000, app) as httpd:
print("listening on port 8000...")
httpd.serve_forever()
Note: When plain domain is used in proxy_pass directive, the domain is resolved once and then cached indefinite. If the domain is public, then you use use variable in proxy_pass with resolver directive to respect DNS TTL. See https://www.nginx.com/blog/dns-service-discovery-nginx-plus/ For instructions on how to setup Nginx for production deployment, see Using Nginx as the reverse proxy.
Add Nginx in docker-compose.yaml:
services:
# Other services are omitted for brevity
nginx:
image: nginx:1.18
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
ports:
- "8080:80"