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
etc.
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 {
proxy_pass http://10.101.1.149/;
}
location /customerB {
proxy_pass http://10.101.2.34/;
}
}
- 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?