Is there any possibility to have two BaseURL WebHostUrl in ServiceStack? - servicestack

We are running AppService in cloud. The WebHostUrl url is stored in web.config file and assigned the url in application start event as like below.
SetConfig(new HostConfig {
WebHostUrl = baseUrl,
);
We have requirement to configure two baseurl in servicestack. That means, the appservice can be accessed either of two url.
https://example1.com/appservice
or
https://example2.com/appservice.
Please suggest how to achieve this.

If you don't specify the BaseUrl ServiceStack automatically uses the URL for the incoming Request.
Basically you don't want to define these URLs in ServiceStack, the 2 virtual hosts should be handled by an external reverse proxy like nginx. The nginx/rsync deployment docs shows an example for how to configure a virtual host to use an Nginx reverse proxy. You'd just need to create 2 virtual hosts for each domain you want to support.

Related

Azure Firewall Routing to multiple backends

We are trying to host multiple sites at the backend of Azure Firewall, however we have about 30 different sites and each with their own test\dev and UAT site, which means 30 x 4 and 120 sites, each one is hosted on port 443, all have their own public IP, and are configured with a DNAT rule for directing the traffic based on the source to the correct backend, we have considered a Azure Application Gateway, with host header redirect, but we haven't had a chance to implement it yet, I was wondering is there a way to be cleverer and use Azure firewall with less public IP's and route to various backends, also the prod public sites have no source specified as they're open to the public.
Hope I've explained that clearly. Thanks
• Yes, what you are trying to achieve is very much possible by creating backend pools of websites according to their purpose, common domain name or the URL path routing. For this purpose, you can use the Azure application gateway efficiently by configuring it with the required features given in it.
First, you can define wildcard hostnames in multiple site listeners for up to 5 hostnames per listener, i.e., suppose you have three domain names under which the multiple various web sites are hosted, then you can create pools of public IP addresses under that respective domain name and ensure that the request for that domain’s website is routed accordingly in application gateway. Similarly, you can host multiple subdomains of the same parent domain on the same application gateway deployment.
For more information on configuring the above, kindly refer to the documentation link below: -
https://learn.microsoft.com/en-us/azure/application-gateway/multiple-site-overview#wildcard-host-names-in-listener
• Also, you can distinguish the requests to each one of the websites with a public IP address by configuring URL based path routing rules for either each one of them or categorizing them into pools of common domain name, common URL path, content to be fetched, common purpose or any such characteristic through which you can make a collection of them. URL Path Based Routing allows you to route traffic to back-end server pools based on URL Paths of the request. One of the scenarios is to route requests for different content types to different backend server pools. Thus, in this way, you can route requests to backend website pools by defining the correct required parametric configurations.
For more information on configuring the above, kindly refer to the documentation link below: -
https://learn.microsoft.com/en-us/azure/application-gateway/url-route-overview\
Also, you can configure request routing rules based on combining the above two features in one. For more information regarding this, kindly refer to the documentation link below which describes in detail when and how you should configure the various path based and listener-based rules in application gateway: -
https://learn.microsoft.com/en-us/azure/application-gateway/configuration-request-routing-rules

Hosting multiple applications using Azure Virtual Machine Scale Sets

Currently we own an application (App-A) which is hosted on Service Fabric cluster using VMSS instances. The VMSS instance has a public IP which points to App-A to route customer traffic. I want to add a new application (App-B) to the same service fabric cluster. How can I use the same VMSS instance to route customer traffic between App-A and App-B?
You can deploy AppB to listen on a different HTTP / HTTPS, that way the applications can run side by side on the same VM instance.
https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-service-manifest-resources
You can use the built-in reverse proxy for this, or a more hardened product like Traefik.
A reverse proxy can look at the requested URL path, querystring parameters or headers, and route the request based on pre-defined rules.
E.g. /svc1/ goes to service 1 and /svc2/ goes to service 2.

Azure front door to support multiple web app by path under same domain

I have a question about azure front door potential for this. So I have 2 web site running by Azure App Services and I need then under same domain name but different path of URL like this:
App Service A -> www.something.com
App Service B -> www.something.com/b-product
I'm not sure this is possible to use Azure front door or I should use another service to solve this problem.
Do somebody can suggestion to me?
Yes you can do this fairly easily, when you create your routing rule you have the option tom specify patterns to match, there you can specify /foo and have this forwarded to pool A where app service A lives
Then you create a different routing rule with /bar pattern to match and forward that to pool B
Then you can repeat this until you get what you need.
you can also have one routing rule match the / domain as per your example you don't have to use a /foo pattern you can also do /* but I always found it easier to use /foo/* and /bar/* to keep the same URL structure
As suggested by Junnas , you can use the front door rules engine
Alternatively , you can use application gateway listeners
If you want all of your requests (for any domain) to be accepted and forwarded to backend pools, choose basic. Learn how to create an application gateway with a basic listener.
If you want to forward requests to different backend pools based on the host header or host names, choose multi-site listener, where you must also specify a host name that matches with the incoming request. This is because Application Gateway relies on HTTP 1.1 host headers to host more than one website on the same public IP address and port. To learn more, see hosting multiple sites using Application Gateway.

How to put an HTTP Gateway on top of Azure Container Instances?

I would like to use Azure Container Instances behind a gateway (HTTP) to avoid an idle infrastructure when there is no traffic.
Something which looks like this.
There is something like that available in Azure ? (like API Gateway in AWS)
Best
There is an Azure template that integrates Application Gateway with Container Instances here. In the example ACIs are deployed in a VNET and the Applications Gateway serves as entry point to the APIs.
You can probably accommodate that templates to fit your requirements.
Step by step:
Upload your images to Container Registry
Create two separate container instances.
Image Type: Private
Fill all required fields, be sure to include the container registry hos name in the image name (the container name can be anything)
Expose your ports in the networking tab
Add a dns name label. Why? Ip can change, see this docs.
Add your env variables if any
It should create them without any problem. Try to access to the dns provided and check if the sites are running properly.
Create new Application Gateway
Fill all required fields (name, tier, whatever...). Use Tier Standard V2.
Public frontend, create new IP address if needed.
Add two bakend pools, use IP or Hostname and provide the dns created in step 2 for each ACI
Add a route: Listener Type: Basic. In Backend targets fill with target type = backend pool, select one of your backend pools and create a new http setting. Literraly fill it with whatever values you want, I coulnd't get this to work in the first page, ever, so I always edit it later.
Add yout tags
Hit create
When it finishes go to your newly created appGateway and search for HTTP Settings.
These are the connection parameters that the appGW uses to connect to your backend, if your backends listens in the same port, the same path and so on you can reuse the HTTP Setting, if it doesn't create 2.
Go to rules and create a path-based rule.
Check your only listener, the default backend and the setting associated with it.
Add a path to your second backend name=endpoint2;paths=_/endpoint2/*_BackendPool=backend2;HTTPSetting=backend2HTTPSetting
And that's it!

Azure Multiple Public IPs on a Virtual Machine Scale Set with Resource Manager

We try to migrate our Platform from classical IIS hosting to a service fabric micro service architecture. So fare we learned that a service fabric lives in a virtual machine scale set and uses Load balancer to communicate to the outside world.
The Problem we now facing is that we have different access points to our application. Like one for browser, one for mobile app. Both use the standard https port, but are different applications.
In iis we could use host headers to direct traffic to one or the other application. But with service fabric we can’t. easiest way for us would be multiple public IP’s. With that we could handle it with dns.
We considered a couple solutions with no success.
Load balancer with Multiple public ip’s. Problem: it looks like that only works with Cloud Services and we need to work with the new Resource Manager World there it seems to be not possible to have multiple public ip’s.
Multiple public load balancer. Problem: Scale Sets accept only on load balancer instance pert load balancer type.
Application Gateway. Seems not to support multiple public ip’s or host header mapping.
Path mapping. Problem: we have the same path in different applications.
My questions are:
Is there any solution to use multiple IP’s and map the traffic internally to different ports?
Is there any option to use host header mapping with service fabric?
Any suggestion how I can solve my problem?
Piling on some Service Fabric-specific info to Eli's answer: Yes you can do all of this and use an http.sys-based self-hosted web server to host multiple sites using different host names on a single VIP, such as Katana or WebListener in ASP.NET Core 1.
The piece to this that is currently missing in Service Fabric is a way to configure the hostname in your endpoint definition in ServiceManifest.xml. Service Fabric services run under Network Service by default on Windows, which means the service will not have access to create a URL ACL for the URL it wants to open an endpoint on. To help with that, when you specify an HTTP endpoint in an endpoint definition in ServiceManifest.xml, Service Fabric automatically creates the URL ACL for you. But currently, there is no place to specify a hostname, so Service Fabric uses "+", which is the strong wildcard that matches everything.
For now, this is merely an inconvenience because you'll have to create a setup entry point with your service that runs under elevated privileges to run netsh to setup the URL ACL manually.
We do plan on adding a hostname field in ServiceManifest.xml to make this easier.
It's definitely possible to use ARM templates to deploy a Service Fabric cluster with multiple IPs. You'll just have to tweak the template a bit:
Create multiple IP address resources (e.g. using copy) - make sure you review all the resources using the IP and modify them appropriately
In the load balancer:
Add multiple frontendIPConfigurations, each tied to its own IP
Add loadBalancingRules for each port you want to redirect to the VMs from a specific frontend IP configuration
Add probes
As for host header mapping, this is handled by the Windows HTTP Server API (see this article). All you have to do is use a specific host name (or even a URL path) when configuring an HTTP listener URL (in OWIN/ASP.NET Core).

Resources