Subdomains and Unbound forward-zones - dns

When using Unbound with forward-zones, does Unbound accept wildcards to help catch subdomains, or must every subdomain be specified by a separate forward zone?
Let's say there is a domain
example.com
with subdomains
s0.example.com
s1.example.com
s2.example.com
…..
s255.example.com
then which if any of the following names will catch all subdomains?
name: "example.com"
name: ".example.com"
name: "example.com."
name: ".example.com."
name: "*.example.com"
This might be considered very basic, but I have searched unbound.net, this site, and elsewhere without finding an answer. Thanks for help.

Try this:
local-zone: "example.com." redirect
local-data: "example.com. A 127.0.0.1"
queries for www.example.com and www.foo.example.com are redirected, so that users with web browsers cannot access sites with suffix example.com
source: https://www.freebsd.org/cgi/man.cgi?unbound.conf
You can also redirect .dev (choose whatever) extension to 127.0.0.1 for example:
local-zone: "dev." redirect
local-data: "dev. 10800 IN A 127.0.0.1"
this will redirect *.dev to 127.0.0.1 which is useful for web developers working with vhosts for example.
source: http://wtf.cyprio.net/wtf/2014-06-22-unbound-catch-all.html

Related

Adding Fastly to a Heroku app does not forward to proper url

I currently have an Heroku app that is being served over a CDN. I have just added Fastly to my Heroku app as an addon and I am struggling to configure it properly. Here is my current configuration:
I have my domain registered on GoDaddy with the following CNAME configuration:
Host: www
Points to: my-site-herokuapp-com.global.ssl.fastly.net
TTL: Custom
Seconds: 600
Here is the GoDaddy forwarding configuration (not sure if this matters):
Forward to https://www.my-site.io/
(301 & forward only)
Here is my fastly configuration:
Domains:
my-site-herokuapp-com.global.ssl.fastly.net
*Provisioned for my-site via Heroku*
my-site.herokuapp.com
*Provisioned for my-site via Heroku*
www.my-site.io
And finally in Heroku in the domains configuration section of my app here are my settings:
Domain Name: my-site.io
DNS target: darwinian-kumquat-123456.herokudns.com
Domain Name: www.my-site.io
DNS target: serene-trout-123456.herokudns.com
Before I tried to make this change I had the CNAME pointing directly to: serene-trout-123456.herokudns.com an it was working fine. However after updating this value to the new Fastly value: my-site-herokuapp-com.global.ssl.fastly.net Fastly directs the site to my-site.herokuapp.com instead of just https://www.my-site.io. I followed the instructions listed here so not entirely sure where I have gone wrong. Any ideas?
Probably because you used redirect 301 and you are using the same browser as before before cleaning cache and data.
301 redirects are recomended only for very limited cases: once done the browsers will NOT refresh again any data from the original server.
There are plenty of posts regarding redirection 301, for example:
Cannot remove 301 redirect
htaccess 301 redirect - how to disable it?
https://www.exai.com/blog/301-redirects

Different ways to do a redirect

I'm working on an old website and I've just found something strange. Www.mysite.com redirects to www.test.com, while mysite.com (non-www) redirects to www.other-site.com.
I've checked the htacces, and it only contains rules to redirect traffic to test.com. www.other-site.com is not present in the file. So how is it possible? Where should I check if there's a rule for this redirect?
Environment:
Centos server /
Apache /
Three sites are on different servers
This could be a DNS issue. If both www.test.com and test.com point to the same server then it is all server side. Virtual hosts can sometimes be the problem if you have Apache set that way then you will need a Virtual host for both www.test.com and test.com. I would say start with the DNS, then the apache config, then the site folder.
Hope that helps.

Redirect all subdomains to main domain by .htaccess

I'm trying to redirect all sub-domains to the root domain. For example, my domain is www.example.com. When someone tries to connect to notexists.example.com, I want to redirect it to www.example.com.
This is first going to be limited to dns.
If DNS is not first setup then the client's web browser won't have an ip address to visit if no DNS records exist for that subdomain, so you will have no way of contacting apache for it to implement a server side redirection.
What you need is a wilcard subdomain/record. This is in the form of an A record:
* 14400 IN A 1.1.1.1
You will access to the httpd.conf file (root access), if you are using cPanel without root access add * as a subdomain:
https://www.namecheap.com/support/knowledgebase/article.aspx/9191/29/how-do-i-create-a-wildcard-subdomain-in-cpanel
If you do have access you will need to set up a virtual host - add the following to your httpd.conf file:
#
# Your VirtualHosts section
#
NameVirtualHost 1.2.3.4
##
# this one accepts any subdomain
##
<VirtualHost 111.22.33.55>
DocumentRoot /www/subdomain
ServerName hostname.domain.com
ServerAlias *.domain.com
</VirtualHost>
http://httpd.apache.org/docs/2.2/vhosts/

Redirecting web content but not the name of web page address

I have two internet addressess, say one.com and two.com
The content of my webpage is all under the domain one.com. If I hit address two.com I want it to redirect to one.com but still with address two.com. For example if I type in address bar two.com/article. I want to still show this same address but the content displayed would be as from address one.com/article
I tried to use htaccess file, but still no luck.
Any advice would be appreciated.
You can't achieve that while performing an external redirect.
If both domains are hosted on the same server, then you can perform an internal redirect (e.g. using Apache's Alias, AliasMatch or mod_rewrite).
If the domains are hosted on different servers, then you would have to proxy one of them. You could do this with ProxyPass from Apache's mod_proxy.
Go to your domain name provider and create an alias (CNAME record) for the address.
You will need to enable mod_proxy in your Apache config for that. Once mod_proxy is enabled, enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory on domain2.com host:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.domain2\.com$ [NC]
RewriteRule ^ http://www.domain1.com%{REQUEST_URI} [L,P,NC]

AppHarbor points my domain to www.hostname.com but not hostname.com

I'm interested in having my website show up for both of these urls - www.example.com and example.com. DNS works properly and redirects www.example.com to 184.72.232.XXX and shows the website but not example.com. I've tried 2 hostname setups:
www.example.com, canonical=true
*.example.com (unable to set canonical)
Both hostname configurations have the same result.
You'll need to add "example.com" too (and keep "*.example.com"). The wildcard only matches subdomains. If you want the www version to be the canonical hostname, you'll need to add that as well.

Resources