[GH-ISSUE #69] Use nginx to redirect from local assets to the standard github live_endpoint #139

Open
opened 2026-03-01 18:33:28 +03:00 by kerem · 4 comments
Owner

Originally created by @sjuerges on GitHub (Aug 3, 2024).
Original GitHub issue: https://github.com/netbootxyz/docker-netbootxyz/issues/69

Is your feature request related to a problem? Please describe.
I want to keep a few things locally that get used very often, but I want to be able to try out everything else via the standard live_endpoint

Describe the solution you'd like
Well, I've built a solution and would like to suggest it here: I have modified the nginx config so that i reads as follows:

server {
        listen 80;

        set $v_filename nf;

        location ~ ^/(.*)$ {
                try_files $uri $uri/ @netboot;
                set $v_filename $1;
                root /assets;
                autoindex on;
        }

        location @netboot {
                return 302      https://github.com/netbootxyz/$v_filename;
        }
}

(code from serverfault i stumbled across some time ago and remembered for this: https://serverfault.com/questions/1099771/redirect-to-other-server-and-domain-if-file-not-found)

This lets me have my cake and eat it too. I can access stuff that isn't there locally, and the nginx sends a 302 to the "standard" live_endpoint url to the client, which then gets it there:

172.18.0.5 - - [03/Aug/2024:21:36:51 +0000] "HEAD /ubuntu-squash/releases/download/7-3e6e05f6/filesystem.squashfs HTTP/1.1" 302 0 "-" "curl/8.4.0"
172.18.0.5 - - [03/Aug/2024:21:36:51 +0000] "GET /ubuntu-squash/releases/download/7-3e6e05f6/filesystem.squashfs HTTP/1.1" 302 145 "-" "curl/8.4.0"

But, i can also access stuff that was downloaded:

172.18.0.5 - - [03/Aug/2024:21:34:45 +0000] "GET /ubuntu-squash/releases/download/5-6efd1d75/vmlinuz HTTP/1.1" 200 11656064 "-" "iPXE/1.21.1+ (g5a9f4)"
172.18.0.5 - - [03/Aug/2024:21:34:46 +0000] "GET /ubuntu-squash/releases/download/5-6efd1d75/initrd HTTP/1.1" 200 46925888 "-" "iPXE/1.21.1+ (g5a9f4)"

Describe alternatives you've considered
I was messing about with caching and i found it ... tedious, to say the least. This is, imho, elegant, ties into the local asset management and SHOULDNT break anything.

Additional context
None. I think its fairly obvious what is happening here. Feel free to contact me for details if anything is unclear ;)

Originally created by @sjuerges on GitHub (Aug 3, 2024). Original GitHub issue: https://github.com/netbootxyz/docker-netbootxyz/issues/69 **Is your feature request related to a problem? Please describe.** I want to keep a few things locally that get used very often, but I want to be able to try out everything else via the standard live_endpoint **Describe the solution you'd like** Well, I've built a solution and would like to suggest it here: I have modified the nginx config so that i reads as follows: ``` server { listen 80; set $v_filename nf; location ~ ^/(.*)$ { try_files $uri $uri/ @netboot; set $v_filename $1; root /assets; autoindex on; } location @netboot { return 302 https://github.com/netbootxyz/$v_filename; } } ``` (code from serverfault i stumbled across some time ago and remembered for this: https://serverfault.com/questions/1099771/redirect-to-other-server-and-domain-if-file-not-found) This lets me have my cake and eat it too. I can access stuff that isn't there locally, and the nginx sends a 302 to the "standard" live_endpoint url to the client, which then gets it there: ``` 172.18.0.5 - - [03/Aug/2024:21:36:51 +0000] "HEAD /ubuntu-squash/releases/download/7-3e6e05f6/filesystem.squashfs HTTP/1.1" 302 0 "-" "curl/8.4.0" 172.18.0.5 - - [03/Aug/2024:21:36:51 +0000] "GET /ubuntu-squash/releases/download/7-3e6e05f6/filesystem.squashfs HTTP/1.1" 302 145 "-" "curl/8.4.0" ``` But, i can also access stuff that was downloaded: ``` 172.18.0.5 - - [03/Aug/2024:21:34:45 +0000] "GET /ubuntu-squash/releases/download/5-6efd1d75/vmlinuz HTTP/1.1" 200 11656064 "-" "iPXE/1.21.1+ (g5a9f4)" 172.18.0.5 - - [03/Aug/2024:21:34:46 +0000] "GET /ubuntu-squash/releases/download/5-6efd1d75/initrd HTTP/1.1" 200 46925888 "-" "iPXE/1.21.1+ (g5a9f4)" ``` **Describe alternatives you've considered** I was messing about with caching and i found it ... tedious, to say the least. This is, imho, elegant, ties into the local asset management and SHOULDNT break anything. **Additional context** None. I think its fairly obvious what is happening here. Feel free to contact me for details if anything is unclear ;)
Author
Owner

@sjuerges commented on GitHub (Aug 3, 2024):

Oh, I would've written a PR if I understood how the initial site-confs/default gets created :) Wasn't trying to be lazy.

<!-- gh-comment-id:2267178327 --> @sjuerges commented on GitHub (Aug 3, 2024): Oh, I would've written a PR if I understood how the initial site-confs/default gets created :) Wasn't trying to be lazy.
Author
Owner

@sjuerges commented on GitHub (Aug 3, 2024):

ah damn, this probably should've gone into docker-netbootxyz issues, right? Sorry, too excited, my bad.

<!-- gh-comment-id:2267178328 --> @sjuerges commented on GitHub (Aug 3, 2024): ah damn, this probably should've gone into docker-netbootxyz issues, right? Sorry, too excited, my bad.
Author
Owner

@antonym commented on GitHub (Aug 3, 2024):

I can move it, if you want to propose a PR, I can find some time to test it out.

<!-- gh-comment-id:2267178329 --> @antonym commented on GitHub (Aug 3, 2024): I can move it, if you want to propose a PR, I can find some time to test it out.
Author
Owner

@sjuerges commented on GitHub (Aug 3, 2024):

I'll write a PR tomorrow, thanks @antonym

<!-- gh-comment-id:2267178501 --> @sjuerges commented on GitHub (Aug 3, 2024): I'll write a PR tomorrow, thanks @antonym
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/docker-netbootxyz#139
No description provided.