Several Starcounter applications on one server with many domains - starcounter

I have seen no built in support in Starcounter to do site bindings, for example in the same way Internet Information Server where you can route calls to a specific site depending on domain name used as per the picture below. Is there any recommended way to how to work do this?

In Starcounter you can setup multiple domains in the ReverseProxies configuration section of the scnetworkgateway.xml file.
Example:
<ReverseProxy>
<DestinationIP>127.0.0.1</DestinationIP>
<DestinationPort>8080</DestinationPort>
<StarcounterProxyPort>80</StarcounterProxyPort>
<MatchingHost>my.website.com</MatchingHost>
</ReverseProxy>
Read more on starcounter.io - Reverse proxy functionality.

Related

Creating custom domain names for api

I have a web server using cpanel and I would like to use a custom domain on one folder for an api. So if I created a folder called api in the public_html folder then the path to that folder would be www.example.co.uk/api/(some php file). How could I change it so the folder would become a custom domain of api.example.co.uk/api/(some php file).
I have looked at a few options but don't really know the best way. I have tried to add a htaccsess file to the api folder and then create a rewrite rule to rewrite the www to api.
I also then looked at creating sub domains with the path to the api folder.
I have read that creating a A record on the server could work but I'm not quite sure how to do this. I know it can be done as most apis use some custom domain like facebooks graph api. (i.e https://graph.facebook.com/youtube/)
This will depend on if you have access to make DNS records for your root domain, example.co.uk. For example right now www. is a CNAME or A record (depends on how your web server is set up), that resolves to the address of your web server. If you made an identical record but named it api. (api. IN A ip-of-webserver), then api.example.co.uk would do the same thing that www.example.co.uk does. This is kind of pointless if they go to the same web server though, the /api/ part of the route makes it clear enough that the routes are for the api. What subdomains like facebook's are doing are pointing to a completely different application, and different web servers. For example, a company may have domains like mail.company.com, portal.company.com, sso.company.com, that all resolve to the address of different web servers for the different apps they have, but in this case it sounds like you are running one web server which is fine, you can have one web server be the api as well as serve the website.

Reverse proxy in Azure with Web Apps

I'm moving from Apache on Linux to Azure Web Apps and I have a specific url (mysite.com/blog and everything under it) that is configured with a reverse proxy so the end user doesn't know that the content is actually coming from another service.
I'm sure I can do this within Web Apps (which runs on IIS) but I can't find any documentation on how to do this. As a backup I'm open to putting another service in front of my Web App.
How can I accomplish this in Azure?
Update: I did try using another service - Functions. My architecture looks like this:
This works in production but I'm hitting snags in development. /blog may or may not work depending on the entry point. In prod, our DNS will be configured so mysite.com points to mysite-proxy.azurewebsites.net and, therefore, any URI the user hits will work. In dev, however, we may want to browse to hit /blog from the Traffic Manager which will route us to /blog on the webapp which doesn't exist. Same problem, of course, if we go to /blog directly on the webapp. I tried to show these examples on the right side of the diagram.
I would like to find a solution so the webapp itself can handle the /blog proxying and then we can determine whether it's worth the speed and cost tradeoff compared to the existing solution.
You might want to checkout Azure Functions Proxies: https://learn.microsoft.com/en-us/azure/azure-functions/functions-proxies
Sounds like you want an Application Gateway (caution, costs like $15/day)
The AGW can have multiple listeners against multiple hostnames, including path-based routing.
You will want to add two backends, one for the /blog endpoint and one for the non-/blog stuff. The backends just take the IP or FQDN of the target resource, in this case you will have:
blogBackend: myblog.com
defaultBackend: myWebapp.azurewebsites.net
Then you need to add listeners for your public-facing domain, it would be like:
myHttpListener: port 80, hostname=mywebsite.net
myHttpsListener: port 443, hostname=mywebsite.net
Then you need an HTTP setting
myHttpSetting: protocol=HTTPS, port=443, useWellKnownCACert=Yes, HostnameOverride=Yes,pick from backend target
Then you need rules, one for http=>https redirect, and the other for handling the pathing
myRedirectRule: type=basic, listener=myHttpListener, backendtargettype=redirection, targettype=listener, target=myHttpsListener
myRoutingRule: type=path-based, listener=myHttpsListener, targettype=backendpool, target=defaultBackend, httpSetting=myHttpSetting, pathRules=
path=/* name=root backendpool=defaultBackend
path=/blog name=blog backendpool=blogBackend
You can create additional http settings and assign them to the path rules to change the behaviour of the reverse proxy. For example, you can have the user's URL be https://mywebsite.net/blog, but have the path stripped on the request to the blog so the request looks like myblog.com instead of myblog.com/blog
There's a lot of tiny parts, but the app gateways can handle multiple applications at scale. Biggest thing is to watch out for the cost since this is more of an enterprise solution.

Block Google Analytics during local testing for static site development without IP ranges (especially on Mobile devices)

I've searched around on SO, and found a few questions that ask about this, but most of the answers that I've come across all seem to suggest either filtering via IP range or introducing conditional code to the engine powering the site; neither of these options are viable for me. If this does turn out to be a duplicate where this an answer that fits in to my use case, then I apologize in advance, but I just can't seem to find anything.
My original method of filtering myself out from Google Analytics was to simply redirect requests to google-analytics.com and the https version of GA to localhost in my hosts file. This works just fine on my desktop, but it is useless when testing on mobile devices like an iPhone (unless somebody knows how to finagle the iPhone's hosts file without jailbreaking).
My setup for local testing is to use pow with .dev domains for the local project directories, and then when I need to see the development version of sites on mobile devices I use Xip.io in conjunction with Adobe Shadow.
I can't filter by IP range because I frequently work from home, and my ISP doesn't provide static addresses for residential accounts.
I tried to set up a Custom exclude filter in my Google Analytics profile to filter out traffic originating from these domains, but they either don't work or I have a really bad misunderstanding of how the Exclude filters work (which is entirely possible). I have Custom Filters set up to Exclude based on the Hostname, matching the patterns \.dev and .*xip\.io/.* but these filters do absolutely nothing. I believe this is because this filter is, technically, looking for the hostname of the originating domain and not the hostname being requested, but I'm really not sure because the language is vague and differs depending on which help document you're looking at.
Short of manually removing the GA tracking codes from the site during local dev then going back and adding them back in, does anybody have any suggestions or can anybody tell me what I'm doing wrong with my Exclude filters?
I've been using a variation on the analytics tracking code to prevent page views from being tracked on our staging server -- something like:
if (!/\.dev|xip\.io/.test(window.location.hostname)) _gaq.push(['_trackPageview']);
Alternatively, you could apply this to the _setAccount call. If you do this and look at the tracking requests, the web property ID shows up as 'UA-XXXXX-X'
You could rely on
window['ga-disable-UA-XXXXXX-Y'] = true;
where UA-XXXXXX-Y is the account ID. (details here).
Like creating a page or webserver directive that sets a cookie (page reserved to developers to be excluded from ga), and in your code that loads ga:
if (hasDeveloperCookie()) {
window['ga-disable-UA-XXXXXX-Y'] = true;
}

how to retrieve a list of domains hosted within a server

is there any way how to retrieve a list of domains hosted within a list of servers, f.e.
trying to find out how many other domains are hosted on the same server, and sharing common resources.
Preferable if this could be used under bash.
/Saulius
You could query this online service with wget or curl... but the form post's procedure looks a bit strange (look at the HTML source code before you use it).
Basically, this is looking-up an IP address in a database of domain names.

Can I find out what domain made a request that triggered an HttpModule?

How do I find out from within an HttpModule what domain made a particular request?
Say I only want to allow site1.com and site2.com to use images from my server, how do I check that it is them making the request?
There's no way to do this in every case. Consider that UrlReferrer may not be set. Also, consider that you could be called by a client that does not have a DNS address.
Instead, you should consider configuring IIS to authenticate using user certificates. If you've only got a small number of sites calling you, generate a certificate, register it with IIS and map to the user you want, then give the certificates to those two machines to be installed on them.
Request.UrlReferrer, but it can easily be spoofed.

Resources