Nginx
Setting up Traffic Splitting with Nginx
Dependencies
Most default installations of NGINX will have ngx_http_proxy_module
already installed and running. To check for this you can run a simple command:
Provided you have got the expected output then you are ready to continue to “Create a rewrite rule” without any further intervention.
Proxy Module Missing
If the output from the above Nginx query is different from the above, then we can access the nginx.conf
file typically located in /etc/nginx/
to validate that the module is loaded, and if not, add it in.
Insert at the top of the file:
You can now test your configuration file for syntax errors:
With no problems reported, restart Nginx to apply your changes:
Create a rule
Insert the following into the configuration file for your domain.
Make sure to replace GLOPAL_HOSTNAME
placeholder with the value you receive from Glopal (for example store-1234.app.glopalstore.com
) and that PATTERN
is a regular expression describing list of in-scope paths you want to delegate to Glopal:
You can now test your configuration file for syntax errors:
With no problems reported, restart Nginx to apply your changes:
Testing your rule
To ensure the rule works as expected, conduct a series of tests by visiting URLs that should be affected by the rule and confirming that they are rewritten correctly.
That's it! You have now created a URL rewrite rule in Nginx.
Last updated