IIS 8.5 Proxy rewrite failing - iis

I'm new to setting up proxy servers. On our actual web server. We have our website and within IIS this sits under wwwroot. I then have 2 other directories outside wwwroot, one with images and one with documents. Before I introduced the proxy the main site had virtual directories to the other 2 areas and all was ok. Moving to a more complex setup I have removed the virtual directories as these need to be re-directed via the proxy. So, basically any address for an image or document from the main site needs to redirect via the proxy to either the images or document area.
I've created 2 more websites in IIS one for documents and one for images and I've set the IP for these to be the same as the main site including the same port. Now moving to the proxy. I've created server farms for all the sites calling them the same name here (dns) as the names on the webserver. This has created default ARR URL Rewrite rules for each server in the farm. I wrote an inbound rule at the Proxy Server level that should redirect the images and using the in-built test showed that I'd put the test together correctly. However, placing it here or on an outbound rule made no difference.
I installed the IIS Trace facility on the proxy and noticed that the test wasn't being hit after looking at the trace logs. I moved my rule to the url rewrite inbound against the default site as opposed to the server. Now in the trace on step 4 I can correctly see that the old url has changed to my newURL and the NewUrl is my expected url, Great!. however, by the time the Trace reaches step 40, it is taking my new correct url as input and removing the domain name for the new url at this step, thus effectively putting the address back to the original. On the inbound rule that made the initial change I have Stop processing of subsequent rules checked.

These are the steps I have done for images and they are finally coming through.
on the web server all my sites have the same IP and port number, only the hostnames are different.
on my local client machine for now in my hosts file I point the main site to the ip of the proxy, but the other sites that I want to redirect to I point their ip to the actual webserver.
in the server the server farm has just 1 ARR entry that is the main site. Leave this as the default, but uncheck the stop processing flag. Create a new inbound URL ReWrite rule for the first redirect. Make the action type a Redirect (not a rewrite this is important.)
On the proxy under the default website, create binding entries for each hostname setting ports the same with ip address set to * then additionally create a blank hostname of the same.

Related

Unusual multiple website setup on Windows Server 2012 R2

I currently have the following website setup on Windows Server 2012 R2. The following website is catching all the traffic to the webserver and then adding a few URL rewrite rules, such as forcing HTTPS and appending www.
I want to add a second website under a subdomain of the above site and diferent source code. How do I go about it?
EDIT: I've created a second website with a binding to the subdomain but all traffic is being redirected to the first website, as setup above. Does the first website require a defined Host Name? If so, that's not possible because the code of the website above is handling about 100 domains. The content is loaded based on domain name. So probably adding a subdomain of one of the websites is not possible. Is someone able to clarify, please?
Just create a new website in IIS for example hostname site1.yourdomain.com and set the bindings and and point to website folder.
create a 2e website with hostname site2.yourdomain.com set bindings, and point to your 2e website folder.
and you can have a main site with hostname www.yourdomain.com or yourdomain.com
also set an ip if you want to bind to a specific ip only.
it is important to set the hostname.

IIS 7 IP address forwarding

I want to move some websites from server 1 to server 2.
My clients have A records pointing to the IP address of server 1. Without updating their DNS records, how can I automatically forward request for those domains from server 1 to server 2?
Thanks
Graham
This image is from an article regarding Exchange, but the IIS settings are relevant.
You can redirect at the HTTP level by specifying a URL redirect in IIS's HTTP Redirect settings:-
However, for this approach to work you will need a new domain for your sites. e.g. if the A record resolves www.example.com to Server 1 you will need to redirect to another URL (e.g. www.example.edu) that already resolves to Server 2.
Another option is to setup a reverse proxy using IIS on Server 1:
Today there was a question in the IIS.net Forums asking how to expose two different Internet sites from another site making them look like if they were subdirectories in the main site.
So for example the goal was to have a site: www.site.com expose a www.site.com/company1 and a www.site.com/company2 and have the content from www.company1.com served for the first one and www.company2.com served in the second one
So slightly different requirements (the article only wants a subdirectory rather than the whole site), but the same concept will apply.

How to run a website in Azure using same URL?

Our company has two sites
www.mysite.com -- Wordpress site
www.mysite.com/portal -- asp.net mvc site
We want to move the wordpress site (www.mysite.com) to Azure and the other site stays local. We need to url stay the same. How can we achieve this?
Since you state that you need the URL to stay the same, this can be achieved through a reverse proxy. You would set up a web server (typically nginx or IIS) answering on www.mysite.com.
This web server would have reverse proxy rules to forward requests for /portal to your on-premises server (in a given, non-public IP and port) and all other requests to another web server running WordPress (on the same server/cluster that runs the reverse proxy, or a separate one), also with a given IP and port.
All user requests, then, would reach the reverse proxy, that would serve them from cache if possible, or forward them to the internal web servers, and send the response back to the user, transparently. Notice that this is an internal operation, not a redirect response.
Although this setup is more complex than the simpler solution of using different subdomains (www.mysite.com for website and portal.mysite.com for application), it comes with certain advantages that are described in the referenced Wikipedia article, such as security and acceleration.
Alternatively you could create separate subdomains as described above, and use a redirect rule to redirect requests for www.mysite.com/portal/x to portal.mysite.com/x. In this case, the user would see the updated URL in their browser, but the old ones would still work.

How to display content from another domain by editing CNAME records?

I have a site that lets people have their own e-stores, for ex- mysite.com/clientname
What I want is, if somebody opens store.clientname.com or clientname.com/store, the content is pulled from mysite.com/clientname. [ So that their users feel that they are browsing on their site ]
I know this is possible because site'e like tumblr let you do that by changing a CNAME entry for your domain to their IP address.
I do have a dedicated IP address.
Also, can this be done by editing the .htaccess file at clientname.com, and if yes, which method is better/easy?
You'll want to solve the problem in a completely different way for http://store.clientname.com/ versus http://clientname.com/store.
In the first case, you can serve the web site as a virtual host. Just set up a virtual host called store.clientname.com and set its DocumentRoot to be the existing directory that contains the files for http://mysite.com/clientname. If you have other web server configuration directives that apply to http://mysite.com/clientname then you'll also want to apply those in the virtual host. Finally, the client can set up a CNAME record in DNS for store.clientname.com pointing to your web server.
If you are using Apache, you can also use a default virtual host and mod_rewrite to dynamically translate URLs of the form http://store.{whatever}/ to http://mysite.com/{whatever}/. However, this won't work if you are using HTTPS.
In the second case, you don't want to serve the web site at http://clientname.com/ because the client presumably is already hosting that and presumably http://clientname.com/otherstuff has to continue working and come from their server. So the second case is easier for you because all the work has to be done on the client's web server. But it's simple: they will just have to configure their web server to proxy http://clientname.com/store to http://mysite.com/clientname.

Using URL Rewrites to allow 1 IP address to host two subdomains

I have a scenario where I need to two different subdomains to come through the firewall and be rewritten or redirected to areas on the server. For example if I have sub1.mydomain.com/testsub1.html entered externally, I want it to hit the IIS "Default web site/folders/sub1/testsub1.html" and likewise, if sub2.mydomain.com/testsub2.html is received I want it to go to "Default web site/folders/sub2/testsub2.html". We were told that URL Rewritew would be the way to go on this. So we set up rules in the Default web site, to use the MatchURL pattern for:
1. sub1.mydomain.com(.) and to rewrite it to "Default web site/folders/sub1(R:1)" with the action type of Rewrite.
2. sub2.mydomain.com(.) and to rewrite it to "Default web site/folders/sub2(R:1)" with the action type of Rewrite.
If I hit http://sub1.mydomain.com/testsub1.html, I get a file not found error. What I am seeing in the logs is the GET /testsub1.html. If I change the URL to http://sub1.mydomain.com/folders/sub1/testsub1.html, it works perfectly and I see GET /folders/sub1/testsub1.html in the logs and the proper page is displayed in the browser.
What am I missing to make this work without the full path?
Bindings are the best way to handle this. They can listen on the same IP address for different hostnames. Create two separate websites in IIS and configure each of their bindings for that particular subdomain.
More information: http://blogs.technet.com/b/chrad/archive/2010/01/24/understanding-iis-bindings-websites-virtual-directories-and-lastly-application-pools.aspx

Resources