Locations are a way to define rules that you can use later in the Servers to send traffic to certain Upstreams (server:port pairs).
For example, you can use regular expressions (regexp) to match certain parts of a URL, so that requests that follow that pattern will be handled differently.
How to Match Queries
Essentially, there are three different kinds of match basis that you can use:
- Exact match (=)
- Starts with (~^)
- Ends with (~*)
On top of that, there are a number of regular expressions operators (
|), quantifiers (
+, etc), wildcards (
*) and grouping patterns (
)) that you can use to further improve your matching patterns.
All of that, however, is out of the scope for this article but you can find out in the Wikipedia entry about regular expressions, and also reading the documentation about the Perl Compatible Regular Expressions (PCRE) module, perlre.
Let’s say that you might want to set up a different Profile for requests that have the term
/images in them.
Once you have a Location for
/images you could cache those requests differently, changing expiry times, limiting requests per second, and much more.
Another example would be a downloads Location.
Once you’ve set the Location you might want to only allow 1 download per user at any given time to prevent excessive use of your bandwidth.
How to Set and Use Locations
Now that you’ve figured that you intend to send different traffic to different Upstreams, let’s see how you do that.
Step 1: Create a Location
First, you will need to create a Location matching a part in the URL that has been requested.
Accelerator > Locations (URLs)
Go under the Add Location tab and give your Location a Name.
Click on Step 2.
Step 2, Option 1: Quick Add
The easiest way to create a pattern is by using the Quick Add [recommended] wizard.
You’ll be offered three options:
- Match a full URL. To match a full URL you’ll enter the entire URL (after the domain). For example:
- Match the start of a URL. To match the beginning of a URL you’ll enter the URL from the first
/up until where you wish to stop matching. For example:
- Match the end of a URL. To match the end of a URL you’ll enter a regex for the last few characters. For example:
The wizard will take care of creating the rule for you.
Once you’re done, click the Save button.
Step 2, Option 2: Manual Entry
If you are a power user and are familiar with regular expressions, feel free to use the Manual Entry [advanced]. This will allow you to customize your matching pattern by using custom regular expressions rules.
Furthermore, you can press the Manual Entry button so that you can also set the Match Basis method.
Again, make you sure that you very familiar with regular expressions and that you know what you’re doing.
To finish, click the Save button.
Step 3: Assign Locations to Servers
A Server is an address which will accept incoming connections to be sent to an Upstream. Here you will specify which Locations should be managed by which Servers.
Accelerator > HTTP Servers (Frontend)
Under the View Servers tab you’ll be able to see a list of your Servers. Click on the Locations button for the Server you intend to assign Locations to.
Once there, you’ll be either Configure or Remove Locations at your discretion.
Managing Your Locations
All Locations are centralized at the Accelerator from where they can be conveniently managed.
Accelerator > Locations (URLs)
With this central management you can use a Location in many servers yet manage what is matched in one place, so if a new file extension appears all of your Servers will be updated at once.