Access to Azure "root" directory producing 404 - azure

ANSWERED THIS MYSELF, BELOW.
I'm buying an SSL Certificate from TheSSLStore.
To authorize my request they need to be able to resolve mydomain.net/randomstring.htm.
The "actual" site is at afunnydomainname.azurewebsites.net.
The specific problem is that I can access the randomstring.htm file in www.mydomain.net but not mydomain.net. And it's got to be mydomain.net/randomstring.htm, because TheSSLStore has a robot that looks for it there.
I have the following DNS records at my domain registrar that point to Azure, shown here.
www.mydomain.net => afunnydomainname.azurewebsites.net ("CNAME" record)
*.mydomain.net => 999.999.999.99 ("A" record, pointing to the real IP address)
mydomain.net => 999.999.999.99 ("A" record, pointing to the real IP address)
These have all propagated, and both www.mydomain.net and mydomain.net are listed in the "Bring External Domains" for afunnydomainname at Azure
When I point FileZilla at afunnydomainname.azurewebsites.net, I see this directory structure:
/
LogFiles
site
wwwroot
In the "/", "site", and "wwwroot" directories, I have placed the randomstring.htm file, along with a web.config file that has <directoryBrowse enabled="true" />;
I can see both files in all three levels in FileZilla.
When I put www.mydomain.net in a browser address bar, I can see the directory with randomstring.htm and web.config.
When I put www.mydomain.net/randomstring.htm in a browser address bar the file opens and I can see the authorization code that TheSSLStore is looking for.
If I put mydomain.net in the address bar I get 404.
If I put mydomain.net/randomstring.htm in the address bar I get 404.
SO, it seems like
a) mydomain.net may not be DNS'ing properly to the "real" root directory on Azure,
b) OR, I don't understand where the "real root directory" is in this scenario,
c) or something else.
Question: What might be the problem and how might I fix it to get 'mydomain.net/randomstring.htm' to resolve?

My Answer:
Was found at this site, from google search "azure A record 404"
http://blogs.msdn.com/b/benjaminperkins/archive/2013/10/01/404-file-or-directory-not-found-when-mapping-custom-domain-to-a-windows-azure-web-site-server-error.aspx
In short, going through the management console in the link above, instead of the new portal, I was able to get the mydomain.net exeternal domain associated with the afunnydomainname.azurewebsites.net site.
So, what happened with the portal "Bring External Domains" function? Did I not press the "save" button? Not likely, since I went in and checked that mydomain.net was there, at least a couple of times, while trying to figure this out.
I hate to think that the management console could do that function more reliably than the portal, but you never know...

Related

IIS: Can I prevent traffic to IP Address and only allow domain name

Since I am using a host header filtering technique in my ASP.NET MVC application, I would like to prevent users from browsing directly to the IP address of my site, and force them to use the FQDN. Is this possible?
I see similar SO question here with no answer
You can do this with Bindings in IIS (assuming you're using IIS): https://technet.microsoft.com/en-us/library/cc731692(v=ws.10).aspx
Open IIS
Right click your site
Click "Edit Bindings"
Edit the entries (http/https) to include a "Host Name" (ex. "YourSite.com", "sub.YourSite.com", etc...)
An alternative would be to force a redirect to the FQDN in your code. You should be able to determine the url using a ServerVariable: https://msdn.microsoft.com/en-us/library/system.web.httprequest.servervariables(v=vs.110).aspx
You can add another Website in IIS, locate it to an empty directory to make it don't do anything useful, use 80 port but don't bind any hostnames. In this case, who access your server by IP directly would just hit this Website, they won't bother you anymore.
Or maybe you can put some helpful webpages in this website to help your client visit by domain name correctly.

How to redirect example.mydomain.com to folder.mydomain.com via DNS/.htaccess?

Is it somehow possible to redirect example.mydomain.com, a subdomain which does not actually exist, to folder.mydomain.com using either .htaccess or DNS? How can this be achieved?
When I access DNS from the control panel and click on the Web DNS tab, I see Personal web DNS settings, under which I believe I can submit domains and their values. However, I am confused with the type (web alias, web forward, A, CNAME, TXT, SRV, AAAA...). Could someone help me?
If the .htaccess way is simpler, I would then prefer it.
Thank you.
You wouldn't be able to use .htaccess as the subdomain does not exist.
I assume, from the process you described, that you are using One.com hosting. If so, the following guide will be of help:
Manage your DNS settings
Essentially, a web forward DNS entry will work for you:
Click on the Web DNS tab.
In the hostname/domain column, enter the subdomain you would like to redirect.
Set the type to web forward
Set the value to where you would like to be redirected when visiting the subdomain.
Click the (+) sign to save your changes.
It will take up to 90 minutes for your changes to take effect.

Cloud Service Custom Domain Redirection configuration

i am not sure whether this correct words to describe the problem, but i try my best to explain.
Suppose i deployed a cloud service with A Name. now client ask me give me something good domain name rather than A.cloudapp.net, so according to need i given him fancy domain name A.myapp.com.
After some time they thinks A is not a good name , give me B. so i change the deployment to B.cloudapp.net and then configured custom Domain Name as B.myapp.com.
Client again comes as says my customer is still using A.myapp.com. Can you do something to redirect them to B.myapp.com. with message that it moved to another address.
As i know i used only CNAME and ARecord on domain registrar . how can show a message over there. That this page is moved to other domain.
If A.myapp.com is no longer in the DNS records then the only way that it's still working is that the DNS propagation hasn't taken full effect yet. That can take even up to a few days. Once that happens then A.myapp.com should no longer resolve. This might also be working if you have a wildcard record for #.myapp.com pointing to the same A.cloudapp.net site.
You can create the A.myapp.com DNS record (if it's not still there) and point it to the same cloudapp.net app again, but then in your cloud app look at the hostname as it comes it to the request. If it is A.myapp.com show them a specific page that reminds them this is now B.myapp.com and then redirect them.

Getting rid of cPanel's default page

I've uploaded my site to my public_html folder, however I'm still getting the default cPanel page.
I've tried using both index.html and index.php files with no success. For some reason it's not realizing that I've got a valid home file in there.
Does anyone have any ideas on how to get this fixed?
Make sure that your domain is configured to point to account IP address. Account IP address you can see in your cPanel user interface in the left info section. Finally, DNS A record of your domain should be equal to it.

Is it possible to make part of a site on IIS only viewable from localhost?

We've got a webserver running IIS. We'd like to run maybe a shared blog or something to keep track of information. Because of security issues, we'd like for that part to be only viewable from localhost so people have to remote in to use it.
So, to repeat my question, can part of a website be made viewable from localhost only?
For some one doing it in IIS 8 / Windows 2012
1) In Server Manager, go to Manage, Add Roles and Features, Next, Next (get to Server Roles), scroll down to Web Server (IIS), expand that row, then expand Web Server, and finally expand Security. Make sure that IP and Domain Restrictions are installed.
2) In IIS Manager, drill down to the folder that you want to protect and left click select it. In the Features View of that folder select IP and Domain Restrictions In Actions choose Edit Feature Settings. Change 'Access for unspecified clients:' to 'Deny' then OK.
3) Finally go to 'Add Allow Entry' In the Actions menu. Type in the Specific IP address of your server.
Now only requests coming from your server will be allowed access. Or any server that shares that IP address. So in a small network, the office could share the IP address between all of the PCs in that offices, so all of those PCs could access that folder.
Last but not least is to remember that if your network has a dynamic IP address, then if that IP changes, you will expose your blog admin folder to whoever is using that IP now. Also, everyone on that new IP address will lose access to your that folder...
You can also use bindings instead of IP restrictions. If you edit the bindings for the web site you want to restrict access to, you can select which IP address the site is available at. If you set the IP address to 127.0.0.1, then the site is only responding on this IP address, and this IP address will of course only work locally on the machine.
I've tested this using IIS 8.5.
In IIS6 you can bring up the properties for the web and click on the directory security tab. Click the button in the middle of the tab for editing the IP and Domain restrictions. On this tab set all computers as denied, then add an exception for the IPs you want to allow access to this site.
I am not sure how to configure this on IIS7. I looked but couldn't find it, if I find it I will edit this answer.
Edit: Configuring IIS7
Josh
Should anyone wish to do this on the command line, this appears to work on IIS 7+
%windir%\system32\inetsrv\appcmd.exe set config "Default Web Site" -section:system.webServer/security/ipSecurity /+"[ipAddress='0',allowed='False']" /commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config "Default Web Site" -section:system.webServer/security/ipSecurity /+"[ipAddress='127.0.0.1',allowed='True']" /commit:apphost
Reference
I initially wanted to do this in web.config to ease distribution, and it looked like the following might work:
<security>
<ipSecurity allowUnlisted="false"> <!-- this line blocks everybody, except those listed below -->
<clear/> <!-- removes all upstream restrictions -->
<add ipAddress="127.0.0.1" allowed="true"/> <!-- allow requests from the local machine -->
</ipSecurity>
</security>
but as you need to unlock the function in the central IIS config anyway there was no advantage over making the change directly using the first commands.
I agree with the recommendations to use IIS "Directory Security" to block all IP address except 127.0.0.1 (localhost).
That said, I'm wondering how this strategy of requiring users to remote in could possibly be more secure. Wouldn't it be more secure (as well as much simpler) to use standard IIS authentication mechanisms rather than have to manage Windows roles and permissions on the server machine?
As suggested in https://stackoverflow.com/a/39870955/2279059, it is possible to configure the site's bindings to listen only on the loopback interface. This makes the site inaccessible from the network without having to use IP address restrictions.
To support both IPv4 and IPv6, add two bindings, one for 127.0.0.1 and one for [::1], and set the hostname to *, so either IP address or localhost can be used to access it as shown in the screenshot:
To add a "local" site programmatically, you can use:
appcmd add site /name:MyLoalSite /bindings:http/127.0.0.1:7103:*,http/[::1]:7103:* /physicalPath:"C:\path\to\site\"
Depending on exactly what you want to happen if an unauthorized user tries to visit it.
You could try to setup the specific section as a virtual directory, then deny view to anonymous users. However, they will be prompted for login, and if they can login then they could see it.
Judging from the options present in the IIS MMC, you can also have a virtual directory only be accessible by certain IP-ranges. You could block everyone but 127.0.0.1. I have not tried this, however.
You can grant or deny access to a site or folder from certain IPs to a site or folder. In IIS, go into properties for the site or folder in question.
(1) Click to the "Diectory Security" Tab
(2) Click Edit Under the "IP Address and Domain Name Restriction" frame.
(3) Click "Denied Access" (This tells IIS to block every IP except those you list)
(4) Click "Add..."
(5) Click "Single Computer"
(6) Enter 127.0.0.1 (the IP of localhost)
Note that it is best to use an IP here (as I've described) rather than a domain name because domains can be easily forged using a hosts file.
You could simply add this .NET to the top of the page.
string MyWebServerName = currentContext.Request.ServerVariables["SERVER_NAME"];
if ( MyWebServerName == "127.0.0.1" || MyWebServerName == "localhost" )
{
// the user is local
}
else
{
// the user is NOT local
}

Resources