Web Gateway is a special Regery service that allows you to associate domain names with the Regery web server. Web Gateway operates at the HTTP protocol layer and offers functions that are typically performed by web servers or reverse proxies.
This kind of service is used as a basic technology for URL Forwarding.
Structure
Domains
Each WebGateway can handle one or more domains assigned to it. The exact allowed amount of domains and allowed domain names depends on where WebGateway is used and what is the end-user's quota. For example, if you add URL Forwarding service to a domain name, then only this domain name and subdomains are allowed to be attached to WebGateway.
For WebGateway service example.com and www.example.com are different domains.
This is an example of Gateway that already has two domains linked
In order to link your domain or subdomain to WebGateway click the 'Link to Domain' button and choose the required template.
Domain name linking is performed in two steps:
Domain name link configuration. This step depends on what kind of link template you are using: URL Forwarding, Masked Redirect or Default Template. All these kinds of templates provide a user interface that allows you to set up required behaviour in the fastest manner. You can easily reconfigure or remove link after it was created.
DNS Configuration. This is an important step that allows you to reference your domain name to WebGateway. If Regery DNS servers are used, then configuration will be done automatically. In case of DNS Resource Records conflicts you will see a conflicts resolution interface that allows you to remove conflicting records. You can also postpone DNS configuration and come back to it later, but keep in mind that without DNS Configuration your domain will not work properly from the internet.
In case if you are not using Regery DNS system DNS Configuration will be performed 'virtually' without actual propagation to DNS servers. That is why it is required to go to your domain DNS provider and copy required DNS Resource records.
Directives
After the domain is added to WebGateway you can start adding Directives.
Directive is some specific rule or action that WebGateway will perform while processing HTTP Requests to your domain.
Allowed set of Directives depends on where WebGateway is used. For example, URL Forwarding allows only URL Action directive to be added.
You can add as many Directives as this specific WebGateway allows. This amount also depends on the end-user's quota.
Some Directives, like URL Action, allow subdirectives to be specified.
URL Action
URL Action directive allows you to set specific rules or actions for some particular HTTP request. HTTP requests can be filtered by URL Path using URL Path Matching rule.
Parameters:
URL Path is a part of URL structure. Generally URL structure looks like: http(s)://<domain-name>/<URL Path>?<URL Query Parameters>.
URL Action Sub-Directive. URL Action only configures HTTP requests filtering based on URL Path and the actual action is configured by Sub-Directive. For example, for URL Forwarding this may be URL Redirect or Masked Redirect sub-directives.
URL Matching Rule - instructs WebGateway how to match URL Path
Exact - request path should fully match URL Path. If you specify a URL path like /some-path/example then URL action will be performed only for queries that have the same path. Example: http(s)://example.com/some-path/example
Prefix - request path should start with URL Path. If you specify a URL path like /some-path/example then URL action will be performed for queries that has start with specified path. Examples: http(s)://example.com/some-path/example/any-sub-paths, http(s)://example.com/some-path/example/, http(s)://example.com/some-path/example
Prefix (stop) - URL Matching Rules are applied one by one according to Matching Order. This kind of rule works in the same way as Prefix rule but once match is found all future matches are skipped.
Regular Expression - request path should match Perl Compatible Regular Expressions (PCRE). If you specify URL Path like ^/myapp/.+\.php$ then all requests starting with /myapp and ending with .php will be handled by URL Action. Example: http(s)://example.com/myapp/sub-path/index.php
Regular Expression (case insensitive) - works in the same way as Regular Expression but without case sensitivity.
4. URL Matching Order:
Prefix (stop) path that matches the query exactly. If found, searching stops.
Prefix and Exact match, looking for the best match. If found, then searching will not stop.
Regular Expressions, in the order they are defined. If found, then found result is used, otherwise, the match from step 2 is used.
So, briefly, Prefix (stop) rule has the highest priority, then goes Regular Expression, then Exact and Prefix.
5. URL Action Description - editable field with some arbitrary text that can briefly describe what URL Action is doing.
URL Redirect
This directive can be used to automatically redirect user to another URL and has such parameters:
Redirect Type - HTTP response code that user will receive from WebGateway
Found (302) - this kind of redirect will not force the browser to cache redirection results. This will allow to test redirection and create not long lasting redirects without browser cache pollution. This option is processed slower because each time a user clicks your links an additional request to the server is sent.
Permanent (301) - this kind of redirect forces the browser to cache redirection results. Returning visitors of your link will see the redirection result much faster.
2. Destination URL - URL that will be used as a redirection target. This parameter allows variables to be used.
URL Redirect directive is available only as sub-directive of URL Action.
Masked Redirect
This directive instructs Web Gateway to return a valid HTML Page to the requesting client (browser) that contains an iframe tag inside that embeds Destination URL. This technology allows to open some arbitrary URL under required domain name (without changing address textbox in browser).
Parameters:
HTTP Code - HTTP response code. By default it is OK (200). Other allowed values: No Content (204), Not Found (404).
Destination URL - URL that will be used as a redirection target. This parameter allows variables to be used.
Title - text inside HTML title tag of returned HTML Page.
Description - description metatag of returned HTML Page.
Keywords - text inside keywords metatag of returned HTML Page.
Masked Redirect directive is available only as sub-directive of URL Action.
Not every URL can be used as a destination. Sometimes web-site administrators forbid sites from being embedded within iframe tag.
Variables
Some WebGateway directives can use built-in and user-defined variables. Most common usage: define URL template for redirection or rewrite rules.
User-Defined variables
User-Defined variables are usually introduced by Regular Expressions placed as a value of URL Action Path. In order to define variables your regular expression should contain a named group with name in format var_<alpha-numeric string>.
Example of regular expression: /subpath/(?<var_path>.*) this regular expression defines variable var_path that can now be used, for example, in URL redirection or rewrite rule. This variable will contain an ending part of URL Path after /subpath prefix. For example, this URL http://example.com/subpath/hello-world.php will create variable var_path equal to hello-world.php
Built-In variables
There is a set of built in variables:
scheme- request scheme, http or https. Example: for URL http://some-example.com/path?p=parameter, variable will be equal to https.
host - unchanged Host header value or, if header not present, domain name. Example: for URL http://some-example.com/path?p=parameter, variable will be equal to some-example.com.
uri - current URI that is processed by Web Gateway. Example: for URL http://some-example.com/path?p=parameter, variable will be equal to /path.
args - arguments in URL Path query string. Example: for URL https://some-example.com/path?p=parameter, variable will be equal to p=parameter.
request_uri - the initial request URI including query string parameters. Example: for URL https://some-example.com/path?p=parameter, variable will be equal to /path?p=parameter.
How to use
In order to insert variable use the following format: ${<variable name>}.
This example will create a URL redirection rule that uses built-in and user-defined variables.
The rule will redirect visitors from address http://example.com/subpath/hello?p=world to address https://another-example.com/subpath/hello/hello?p=world