If you are willing to help hiproxy to write documentation, please contact zdying@live.com, thank you!
Code block
There are three categories of code block in hiproxy:
- global block: All configurations which are not in other blocks, are in global block;
- domain block: It’s nested in global block;
- location block: It’s nested in domain block;
Scope
There are five types of scopes that are involved in the configuration file:
- global scope: The scope is corresponding to global block. The variables in the global scope can be accessed everywhere;
- domain scope: The scope is corresponding to domain block.
- location scope: The scope is corresponding to location block.
- request scope: A implicit scopre which is not corrsponding to any code block. The directives in the scope are distributed across any code block.
- response scope: A implicit scopre which is not corrsponding to any code block. The directives in the scope are distributed across any code block.
Code block hierarchy
1 | global |
Looking for variables
Here are rules for looking for variables in current scope:
- While the varialbe is in current scope, its value should be returned.
- Looking for the varialbe in upper level scope, and return the value if it’s found.
- Otherwise, if upper scope is global scope, the variable name (include
$
character) should be returned. - Repeat steps [2-3].
Execute directive
The directive in the code block executes automaticlly at the appropriate time (request/response). The directives in upper scope execute too.
1 | www1.test.com => { |
In the configuration, if the directive at #2, #3 or #4 executes, the one at #1 would execute too. That means:
A request for /
, /index.html
or /\/(native|gallery|picture|font)\/(.*)/
should be add a Host
header, which has www.test.com
as value.