我可以使用 Varnish 重新格式化我的 URL 参数吗
我有一个相对简单的(我认为)用例,但我找不到任何有人这样做的例子。我们在两个不同的应用程序之前使用 Varnish 作为缓存和反向代理,并希望使两者之间的事情更加统一,因为它们都做类似的事情。我希望 Varnish 可以帮助重写 URL,如下所示。
用于分页的原始应用程序 URL(获取前 10 项):
http://myapplication.com/products/?startindex=1&endindex=10
所需 URL:
http://myapplication.com/products/?paginate=1:10
这只是一个示例(最复杂的示例,因为它结合了两个参数),但在所有情况下,参数的输入值都保持不变,只是参数名称将会改变。
另一个例子是:
http://myapplication.com/search/?query=something
到:
http://myapplication.com/search/?q=something
有谁有清漆的经验以及如何做到这一点?
谢谢
I have a relatively simple (I think) use-case but I can't find any examples where someone has done this. We are using Varnish as a cache and reverse proxy in front of two different applications and would like to make things a bit more unified across both as they both do similar things. I was hoping Varnish could help rewrite the URLs as shown below.
Original application URL for pagination (get first 10 items):
http://myapplication.com/products/?startindex=1&endindex=10
Desired URL:
http://myapplication.com/products/?paginate=1:10
This is just one example (the most complex because it combines two parameters), but in all cases the input values for the parameters stay the same, it is just that the parameter names will change.
Another example would be:
http://myapplication.com/search/?query=something
to:
http://myapplication.com/search/?q=something
Does anyone have any experience with varnish and how this could be done?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然你可以。答案是 regsub 是你的朋友。
例如:
这会将传入的“id”参数转换为后端的“byGuid”参数。 t 还对 URL 字符串的其余部分做了很多事情,但基础知识就在那里。因此,如果有人想做类似的事情,这是一个很好的起点。
Apparently you can. The answer is that regsub is your friend.
For example:
This will convert and incoming "id" parameter into a "byGuid" parameter on the backend. t also does a bunch of stuff with the rest of the URL string but the basics are there. SO if anyone wants to do something similar this is a good starting point.