Last active
June 22, 2020 17:43
-
-
Save altaurog/0471a50535662823b4b54f6e7e3abd7b to your computer and use it in GitHub Desktop.
starlette on docker x-forwarded-proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from starlette.requests import Request | |
from starlette.responses import JSONResponse | |
async def app(scope, receive, send): | |
request = Request(scope, receive) | |
response = JSONResponse( | |
{"scheme": request.url.scheme, "headers": dict(request.headers),} | |
) | |
await response(scope, receive, send) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM debian:10-slim | |
RUN apt-get update && \ | |
apt-get install -y --no-install-recommends \ | |
gcc make python3 python3-dev python3-pip | |
RUN pip3 install setuptools wheel | |
RUN pip3 install uvicorn starlette | |
COPY app.py app.py | |
CMD ["uvicorn", "app:app", "--port", "8080", "--host", "0.0.0.0", "--proxy-headers"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
package versions:
httptools==0.1.1
starlette==0.13.4
uvicorn==0.11.5
uvloop==0.14.0
running locally with
uvicorn app:app --port 8080 --proxy-headers
:running with
docker run -p 8080:8080 --rm -it httpsmwe:latest
: