Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

template: support more functions like view #6641

Open
tianon opened this issue Apr 25, 2024 · 1 comment
Open

template: support more functions like view #6641

tianon opened this issue Apr 25, 2024 · 1 comment

Comments

@tianon
Copy link

tianon commented Apr 25, 2024

What would you like to be added:

Specifically, it'd be nice to have something like view's incidr function in the template plugin, especially for changing responses dynamically based on .Remote

Why is this needed:

My use case is that I want to change a whole list of hostnames to return a specific IP address, but it needs to be different based on the IP of the requestor (so that their path to the resource is correct) because my server sits on multiple different networks, so each network's hosts need to connect to it via the correct network-local IP.

I could implement this with view instead, but then I have to maintain several server blocks instead of just a slightly more complex template 👀

@tianon
Copy link
Author

tianon commented Apr 29, 2024

In case it helps someone else, I ended up with a solution where I have a single top-level hostname that I use view to vary the response to based on client IP, and then my more complex blocks can simply CNAME to that top-level hostname and get the desired behavior. This does mean an extra hop in all the responses and an extra exposed hostname, but it works reasonably well.

I do still think it'd be cleaner/better to have support for more useful template functions in template 😄 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant