Welcome! Log In Create A New Profile


path based routing as a reverse proxy

Posted by bmenate 
path based routing as a reverse proxy
August 04, 2021 09:01AM
We were looking to use the AWS application load balancer (ALB) to direct incoming requests to specific servers where a "tenant" may reside. For example - customerA signs up to our free trial and we provision them a new instance of our application on webserver1 and we send them a link to their app, eg. https://trial.our.app/customerA
What we need is for our automated deployment that we will design and develop to ensure that when that person hits the load balancer it directs them to the appropriate server. However, from what we understand the AWS ALB has a rule limit of 100 rules therefore if we hit 100 free trials we would have run out of rules :
if path is '/customerA/*' then forward to webserver1
if path is '/customerB/*' then forward to webserver1
if path is '/customerX/*' then forward to webserver2
if path is '/customerY/*' then forward to webserver3
Also, if the customer browses to the "root" https://trial.our.app it redirects them to our website free trial page (different URL, eg. https://ourwebsite.io/freetrial)
We're not looking to load balance, it will simply be a case of redirecting the customer to their appropriate webserver where they have been provisioned.
We're considering NGINX (and are new to it!) and have spun it up to test this out and it mostly works, however we are unsure of a few things:
- what would a basic/sample configuration of this look like? what he have so far on our test is as follows:
server {
listen 80;
listen [::]:80;
server_name _;
root /usr/share/nginx/html;

# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

error_page 404 /404.html;
location = /404.html {

error_page 500 502 503 504 /50x.html;
location = /50x.html {

location = / {
return 301 https://ourwebsite.io/freetrial;

location /customerA {
location /customerB {

- how do we ensure the location path is case insensitive, processes and includes everything after the path , eg. https://trial.our.app/customerA/#/app
- how would you go about automating this so that the nginx config is updated when a new customer signs up and is added to the list of "locations" in the nginx.conf file?
- any other suggestions of how best to approach this? are we using the right approach?
Re: path based routing as a reverse proxy
August 04, 2021 11:59AM
I asked this question in other forums and got a really good response here: https://www.reddit.com/r/nginx/comments/oxr2z8/path_based_routing_as_a_reverse_proxy/
Re: path based routing as a reverse proxy
August 04, 2021 05:04PM
Your google keywords for today are: Lua, Redis, Openresty.

nginx for Windows http://nginx-win.ecsds.eu/
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 81
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready