It’s been forever since I edited the HAProxy file. I had been using a GUI for it and I forgot a lot of stuff.
I didn't have much luck with the docs. (click for more details)I’m trying to use a section of the path in a request to compose the subdomain string and use it to send it in the Host header.
The “variables” doodled in the screenshot don’t exist or match anything else in the picture. They’re only there to show more or less my idea of their syntax, so hopefully somebody would correct me.
I though about two 1½ ways of doing it, one is using {I forgot the name just now}, but what I mean is that sort of regex string manipulation shown in the line with set-header in the picture above.
The other is more or less the same, but taking from var(txn.txnpath)[1] what’s needed, the second (\2) capture group from ^(\/)([^/]*)(.*)$[2] set that into another variable then call it again from the set-header line, hopefully. I figured that this way although it’s an extra step, I’d also have an extra variable available for use in some other manipulation, right?? IDK it’s probably nonsense.
Of course I could just assemble the strings myself because — yes — I am aware that since what I’m matching is exactly what I am attempting to rewrite, I could just directly write the rule and be done with it since I know the values needed, and wouldn’t likely be creating something close to a wildcard-matching security compromise. But then I wouldn’t learn anything, and as it is I’m breaking the one rule I have which is not to write code (i.e. copy and paste) that I don’t understand. I never thought about what would or should I do if I stopped understanding it and it’s driving me a little insane.
I’m open to any advice/suggestions even if unrelated. Thanks!
which BTW I don’t completely remember how are these set; I rescued my config file from the last time I used HAProxy without a GUI hence the existing code syntax. I wasn’t an expert but I felt very natural by the end of it, even the layout looked like more like stats than syntax. ↩︎
in other words: whatever’s between the first or leftmost set of
/s in the path where the rightmost/is optional ↩︎
1 post - 1 participant
