Block access to a redirected subdomain on an IP basis - .htaccess

I have a subdomain (mail.mywebsite.com) that points to the login page that I've set up for Google apps (per their instructions). I'm currently using a CNAME record to point users to the page.
However, I'd like to restrict access to this subdomain on an IP basis (effectively create a whitelist).
Not sure if modifiying .htaccess on my server is an option, as the domain is configured in the registrar to forward to Google, not content on my server.
Any suggestions for how I could accomplish this? Thanks in advance!

If you've done this using a DNS CNAME, you have no control over who can access mail.mywebsite.com since it's not even your server that's accepting requests (it's Google's server).
Unless there's some way to setup access restrictions on Google, there's not going to be anything that you can do.
Alternatively, you can change the CNAME to point to your server, then use a reverse proxy to proxy the requests to Google. You can then use access controls to setup what IPs will be proxied and all the rest will just get 403'ed. Can't setup ProxyPass in htaccess file though, need to do it in server/vhost config, but you can use the P flag in mod_rewrite to reverse proxy for you.

Related

Redirect www to non-www on Azure Dns Zone

I have created Azure DNS Zone to manage redirections which use domain from namecheap.
Let's assume that my website is www.johndoe.com and currently website working well for johndoe.com but when I call www.johndoe.com it doesn't work well.
I have CNAME record and in CNAME redirect to redirect but unfortunately it doesn't work.
When I have call www.johndoe.com response message is as following...
Our services aren't available right now
We're working to restore all services as soon as possible. Please check back soon.
Please take into account that DNS does not provide a redirect.
An additional A or CNAME record only provides your IP address to people that navigate to that specific URL. When www.johndoe.com and johndoe.com both resolve to your web server, this means each page on your site has two addresses. This is horrible for things like SEO.
For a true redirect (and a 301 is preferred for SEO), set something up in the service that's handling the traffic coming in.
For instance: if you have an App Service running ASP.NET, setup the redirect in web.config. If you have Front Door (or a CDN) in place, use the rules engine to create a redirect with the correct condition and action.
Here's an example redirect in an Azure Front Door Classic Resource (this one redirects the other way):

Possibility to host site content on one domain and access it via another

I have site1.domain1.com and site2.domain1.com
Is it possible to access to site2.domain1.com via domain2.com via cname or some other possibility?
So idea is to has content hosted at our server and allow user to access it via their own domain.
Is it possible somehow?
thanks
Regards,
Ilija
Both domain should point to same IP direction to get the same site. You need to configure your second domain domain2.com with same IP direction than site2.domain1.com

How to allow CNAME pointed to my server / how to use subdomain for a different server?

We create custom web apps for businesses and for the first time a client of ours has asked that instead of using our subdomain and instead of using a custom domain for their web app they would like to use their own subdomain for a domain currently hosted on another server.
For instance our domain is webapp.com and their domain is business.com. They would like app.business.com to be point to our name servers so we can continue hosting the web app for them.
I know it's possible to do this because we currently have outgoing CNAMEs on our server for help desks, etc, that aren't hosted on our own server but are using subdomains of ours.
Could you help me with what our client has to do on their zone editing side and what we need to do on our WHM/cPanel side to allow this?
NOTE: We had the client create a CNAME for app.business.com. pointed to our nameserver ns1.webapp.com and then we created an add-on domain for business.com and subdomain for app.business.com but when you try to visit app.business.com it gets the "Sorry!" cPanel page.
Thank you!
Alright I figured out how to do it on my own after a lot of testing & thought I'd post here to help others out in case they run across this in the future.
For the server with the subdomain on it have them create an 'A' record for that subdomain pointing to your server's IP address like so:
subdomain.business.com. ((note the extra period at the end is required))
TTL: 14400
Record Type: A
Pointing To: Your server's IP address.
Now on your server's cPanel you will need to create an addon domain for THAT subdomain (ie subdomain.business.com) - not for the actual business.com domain but for the entire subdomain subdomain.business.com with the folder being the root folder wherever you would like it to show.
That worked for me!
The CNAME should not point to your nameserver but your subdomain f.e. client1.webapp.com.
An other solution could be to add the subdomain app.business.com to your server and the client add an A record for the subdomain to your ip.

Client cname pointing to my domain on cloudflare

A client of ours has the domain client.com
Our application is at superapp.mycompany.com
We want the client to be able to access our application via their own subdomain, like: superapp.client.com.
Normally we'd just tell the client to add a cname for superapp and point it to superapp.mycompany.com. Then on our server (IIS) we'd bind their domain to our app and everything would work as intended.
However, we can't replicate this functionality when our mycompany.com domain is managed via cloudflare.
When we navigate to superapp.client.com we get the following error page:
Error 1001
What happened?
You've requested a page on a website (superapp.client.com) that is on the Cloudflare network. Cloudflare is currently unable to resolve your requested domain (superapp.client.com).
Is there any way that Cloudflare can be used in this fashion?, this seems like a pretty standard set up for a multi tenant application that supports custom domains.
We don't need all the protection that Cloudfront offers for these client domains, but we want to use the Cloudfront nameservers for out application (mainly for fast switching of DNS records in the event we migrate servers, etc).
Any help is appreciated.
I hope it's not too late. But just found a way to do so.
You just need to add your client's domain (Add site in Cloudflare) to your account.
You don't need to change client domain's NS. So in your Cloudflare panel this domain will showing as "Pending Nameserver Update".
Next step is add the CName record to this domain.
Although the NS of client domain is not changed to CF, but CF has a lookup record as CName for it.
Hope it helps.
Just in case someone arrived here with same issue as me. Here is the answer. For short, no that won't work.
Since Cloudflare is a reverse proxy for the domain that is on Cloudflare, the CNAME redirect for the domain (not on Cloudflare) wouldn't know where to send the traffic to.
Ref: https://support.cloudflare.com/hc/en-us/articles/360017421192-Cloudflare-DNS-FAQ#CloudflareDNSFAQ-CanICNAMEadomainnotonCloudflaretoadomainthatisonCloudflare
If you don't need the CDN benefits, you can still use Cloudflare nameservers to manage your DNS zone and keep your current configuration. Just make sure the CDN is deactivated for the target subdomain in your zone (superapp.mycompany.com in your case).
You can tell if the CDN is activated or deactivated for a subdomain by looking at the cloud icon on the right of each DNS entry: if the cloud is orange the CDN is active, if it is gray, it isn't.
Cloudflare also supports external CNAME resolution in their CDN infrastructure, but it's only available for its Enterprise customers:
https://support.cloudflare.com/hc/en-us/articles/217371987-Managed-CNAME

Domain forwarding (sort-of)

I have been attempting to set up magento on a shared hosting server that doesn't support innoDB, ergo its not been possible. The domain I want to use has also been registered with this rubbish hosting provider. (one[dot]com for anyones reference). So I thought I would be able to point this domain to a different hosting provider that DOES support it, but one[dot]com doesnt allow me to change nameservers for the domain. They just said this:
You can only setup IP address, CNAME and web forwarding in our DNS settings but not change of nameservers
Would there be any way to change any of these settings or the .htaccess file so that, for example
http://www.mydomain.com/folder/page.php?query=string
Would display a page from the other server
http://xxx.xxx.xxx:xx/folder/page.php?query=string
I've created loads of sits doing all sorts but never really needed to other with the domain administration side of things.
You don't need to change name servers to map a domain to a different server. If the "good" provider supports it (i.e. allows you to register a domain on the server that isn't hosted by the company), just switch the A and MX records to the new server's IP address.
You do need the cooperation of the "good" provider for this, though.
If they're letting you set up the IP address, then setting the IP address of www.mydomain.com to xxx.xxx.xxx.xx should do the trick. On the other server, you'll need its webserver to be set up to serve www.mydomain.com as a virtual domain - if you're using a hosting provider they should do this for you; if not it should be fairly easy to set up (consult the manual of whichever web server software you're using).

Resources