Skip to content

Proxy Rules

Salar K edited this page Nov 19, 2022 · 6 revisions

When in Smart Rules profile type, the decision to decide whether to apply to a request is made using Rules. Rules can be defined from the Add Rule popup window or from the popup menu in the browser toolbar.

In order to understand the rules you should know their types.

image

Rule Types

Currently these are the types of the rules that can be used to add rules within a Smart Rule profile.

  • Host Wildcard (Match Pattern)
    Uses match patterns on host name
  • Url Wildcard (Match Pattern)
    Uses match patterns on url
  • Host regex
    Uses regex expressions on host name
  • Url regex
    Uses regex expressions on url
  • Exact Url
    The exact url should match
  • DomainSubdomain
    Matches root domain and all subdomains of the expression.

From this list the type DomainSubdomain is the one that is used when a new rule is added from the popup menu of the browser. That is the simplest and also fastest in terms of performance impact.

What is a Host?

Host is used in rules a lot so it is important to know the exact meaning.

As per MDN:

The host property of the URL interface is a string containing the host, that is the hostname, and then, if the port of the URL is nonempty, a ':', followed by the port of the URL.

let url = new URL('https://developer.mozilla.org/en-US/docs/Web/API/URL/host');
console.log(url.host); // "developer.mozilla.org"

url = new URL('https://developer.mozilla.org:443/en-US/docs/Web/API/URL/host');
console.log(url.host); // "developer.mozilla.org"
// The port number is not included because 443 is the scheme's default port

url = new URL('https://developer.mozilla.org:4097/en-US/docs/Web/API/URL/host');
console.log(url.host); // "developer.mozilla.org:4097"

Now that the meaning is clear let's dig into the details of each rule type.

DomainSubdomain

This type of rule only requires the Rule Source Domain.

The rule is very simple, host name will be used to match the rule expression and also its subdomains.

DomainSubdomain Match Doesn’t Match
example.com example.com
www.example.com
sub.example.com
sub1.sub2.example.com
example.com:80
sub.example.com:80
example.com:443
sub.example.com:443
example.com:2030
xample.com
example.net
sub.example.com sub.example.com
sub2.sub.example.com:80
other.example.com
sub.example.com:2020
example.com:8080 example.com:8080
sub.example.com:8080
example.com:80
example.com:443

Note: 80 and 443 are the scheme's default port and if the rule doesn't specify port number these defaults may apply.

Host Wildcard (Match Pattern)

In short Match Patterns are simple versions of Regex specialised for URLs. If you want to read more about it please head to MDN.

With this rule Host name will be used for matching. The patterns should accommodate for the hostname matching only otherwise they won't be accepted.

Here are some examples:

Host Wildcard (Match Pattern) Match Doesn’t Match
*.example.com/*
*.sub.example.com/*
*.example.com:8080/*

Url Wildcard (Match Pattern)

Very similar to Host Wildcard (Match Pattern) but instead of hostname the whole Url of the request will be used for matching.

Also the patterns should accommodate for Url matching otherwise they won't be accepted.

Here are some examples:

Host Wildcard (Match Pattern) Match Doesn’t Match
*://*.example.com/*
*://*.sub.example.com/*
*://*.example.com:8080/*

Host regex

TBC...

Url regex

TBC...

Exact Url

TBC...