[GH-ISSUE #491] Serve video #180

Closed
opened 2026-02-25 22:34:32 +03:00 by kerem · 4 comments
Owner

Originally created by @w3blogfr on GitHub (Sep 6, 2024).
Original GitHub issue: https://github.com/flyimg/flyimg/issues/491

Originally assigned to: @sadok-f on GitHub.

Hello,

I'm using S3 to have photo and video

Actually, flyimg is able to serve thumb picture for on image from a video. For that, flyimg download the video and save in tmp folder.

As flyimg have to download the full video anyway to capture one specific image from that video, why it's not possible to serve the video directly without any transformation?

I use flyimg as cache to save some cost by not using S3 to serve image, allow to serve a video will provide a single entry for both format.

Regards.

Originally created by @w3blogfr on GitHub (Sep 6, 2024). Original GitHub issue: https://github.com/flyimg/flyimg/issues/491 Originally assigned to: @sadok-f on GitHub. Hello, I'm using S3 to have photo and video Actually, flyimg is able to serve thumb picture for on image from a video. For that, flyimg download the video and save in tmp folder. As flyimg have to download the full video anyway to capture one specific image from that video, why it's not possible to serve the video directly without any transformation? I use flyimg as cache to save some cost by not using S3 to serve image, allow to serve a video will provide a single entry for both format. Regards.
kerem 2026-02-25 22:34:32 +03:00
Author
Owner

@w3blogfr commented on GitHub (Sep 7, 2024):

At the end, I created a second nginx container and used it as a cache for my bucket s3


events {
    worker_connections 1024;
}

http {
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    # Logs configuration
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    # Cache configuration
    proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=my_cache:10m max_size=${CACHE_SIZE} inactive=60m use_temp_path=off;

    # Include virtual host configurations
    #include /etc/nginx/conf.d/*.conf;
    #include /etc/nginx/sites-enabled/*;

    # Your server block goes here
	server {
		listen 80;  # Le port sur lequel Nginx écoute
		server_name localhost;  # Vous pouvez ajuster cela si nécessaire

		location / {
			proxy_pass https://${PROXY_HOST};
        
			# Proxy headers pour passer correctement les informations au serveur en amont
			proxy_set_header Host ${PROXY_HOST};  # Remplace l'en-tête Host par le domaine de S3
			#proxy_set_header Host $host;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header X-Forwarded-Proto $scheme;
			
			# Assurer que les paramètres de la requête sont transmis correctement
			proxy_set_header Accept-Encoding "";
			proxy_set_header Cache-Control "";
			proxy_set_header Pragma "";
			
			# Assurer que Nginx ne modifie pas les paramètres de la requête
			proxy_pass_request_headers on;
			proxy_pass_request_body on;
			
			# Activer SNI pour passer le nom du serveur lors de la négociation SSL
			proxy_ssl_server_name on;

			# Cache settings
			proxy_cache my_cache;
			proxy_cache_key "$scheme$request_method$host$request_uri$is_args$args";
			proxy_cache_valid 200 302 24h;
			proxy_cache_valid 404 1m;
			proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;

			add_header X-Cache-Status $upstream_cache_status;

			# Intercepter les erreurs pour éviter que Nginx cherche des fichiers locaux
			proxy_intercept_errors on;
		}
	}
}
<!-- gh-comment-id:2335200063 --> @w3blogfr commented on GitHub (Sep 7, 2024): At the end, I created a second nginx container and used it as a cache for my bucket s3 ``` events { worker_connections 1024; } http { sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; # Logs configuration access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; # Cache configuration proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=my_cache:10m max_size=${CACHE_SIZE} inactive=60m use_temp_path=off; # Include virtual host configurations #include /etc/nginx/conf.d/*.conf; #include /etc/nginx/sites-enabled/*; # Your server block goes here server { listen 80; # Le port sur lequel Nginx écoute server_name localhost; # Vous pouvez ajuster cela si nécessaire location / { proxy_pass https://${PROXY_HOST}; # Proxy headers pour passer correctement les informations au serveur en amont proxy_set_header Host ${PROXY_HOST}; # Remplace l'en-tête Host par le domaine de S3 #proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; # Assurer que les paramètres de la requête sont transmis correctement proxy_set_header Accept-Encoding ""; proxy_set_header Cache-Control ""; proxy_set_header Pragma ""; # Assurer que Nginx ne modifie pas les paramètres de la requête proxy_pass_request_headers on; proxy_pass_request_body on; # Activer SNI pour passer le nom du serveur lors de la négociation SSL proxy_ssl_server_name on; # Cache settings proxy_cache my_cache; proxy_cache_key "$scheme$request_method$host$request_uri$is_args$args"; proxy_cache_valid 200 302 24h; proxy_cache_valid 404 1m; proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504; add_header X-Cache-Status $upstream_cache_status; # Intercepter les erreurs pour éviter que Nginx cherche des fichiers locaux proxy_intercept_errors on; } } } ```
Author
Owner

@sadok-f commented on GitHub (Sep 9, 2024):

thank you @w3blogfr for suggesting this feature.
I think it's feasible from the code perspective, to just return the source video and save it to the cache.
but do you still need it after adding your second nginx setup?

<!-- gh-comment-id:2337630807 --> @sadok-f commented on GitHub (Sep 9, 2024): thank you @w3blogfr for suggesting this feature. I think it's feasible from the code perspective, to just return the source video and save it to the cache. but do you still need it after adding your second nginx setup?
Author
Owner

@github-actions[bot] commented on GitHub (Oct 10, 2024):

This issue is stale (30 days with no activity)

<!-- gh-comment-id:2403821706 --> @github-actions[bot] commented on GitHub (Oct 10, 2024): This issue is stale (30 days with no activity)
Author
Owner

@github-actions[bot] commented on GitHub (Oct 25, 2024):

This issue was closed (14 days since being marked as stale)

<!-- gh-comment-id:2436696090 --> @github-actions[bot] commented on GitHub (Oct 25, 2024): This issue was closed (14 days since being marked as stale)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/flyimg#180
No description provided.