Last active
December 5, 2022 12:17
-
-
Save nnfuzzy/50151e817d752c9941f83c1770f74626 to your computer and use it in GitHub Desktop.
python fastapi with nginx and byte range (e.g important for video streaming into apple devices)
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
#Use FileResponse in FastAPI | |
#docker-compose.yml | |
version: '3.3' | |
services: | |
web: | |
build: ./services/web | |
command: gunicorn -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000 project:app | |
expose: | |
- 8000 | |
volumes: | |
- ./services/web/:/usr/src/app/ | |
#ports: | |
# - 8000:8000 | |
env_file: | |
- ./.env.dev | |
nginx: | |
build: ./services/nginx | |
ports: | |
- 80:80 | |
depends_on: | |
- web | |
#nginx.conf | |
upstream fast_api_application { | |
server web:8000; | |
} | |
server { | |
listen 80; | |
location / { | |
proxy_buffering off; | |
proxy_buffer_size 16k; | |
proxy_busy_buffers_size 24k; | |
proxy_buffers 64 4k; | |
proxy_force_ranges on; | |
proxy_pass http://fast_api_application; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $host; | |
proxy_redirect off; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment