Authgear has an internal endpoint that can authenticate HTTP request.
Prerequisite
You must follow 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()
Run it with:
python3 app.py
Make the application server a service in docker-compose.yaml
We have to write a Dockerfile for our application server.
FROM python:3.7-slim
COPY app.py .
EXPOSE 8000
CMD ["python3", "app.py"]
We then declare it as a new service in docker-compose.yaml:
services:
# Other services are omitted for brevity
app:
build:
context: .
ports:
- "8000:8000"
Finally, run it!
docker-compose up
Add Nginx
Copy the following nginx.conf and save it as nginx.conf.
Visit to verify our application server is working with docker-compose.
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 For instructions on how to setup Nginx for production deployment, see .
Visit to reach Authgear and the application server.