Koozali.org: home of the SME Server

DNS define domain without prefixes

Offline cyberfido

  • 13
  • +0/-0
DNS define domain without prefixes
« on: July 15, 2014, 11:55:41 AM »
Hi all,
I have a problem about a redirection.
I have a SME Server 8 used a server domain and I have a website (hosted externally) that responds to www.mysite.com and also to mysite.com.
Externally all goes well, but internally (behind the SME) when I type mysite.com, it redirects to the webpage of the SME itself saying "This web site is under construction"
Trying to ping mysite.com confirms me that it is resolved by the IP of the SME.
Is it possibile to write a redirection tof mysite.com to the external static IP of the site's server, like I've already done with the others subdomains?
Otherwie I cannot reach the site (using mysite.com) from our LAN.
Thank you very much.

Offline Stefano

  • *
  • 10,839
  • +2/-0
Re: DNS define domain without prefixes
« Reply #1 on: July 15, 2014, 12:35:12 PM »
how did you setup your domain?

Code: [Select]
db domains show mysite.com

Offline cyberfido

  • 13
  • +0/-0
Re: DNS define domain without prefixes
« Reply #2 on: July 15, 2014, 12:42:47 PM »
mysite.com=domain
    Content=Primary
    Description=Primary domain
    Nameservers=localhost
    Removable=no
    SystemPrimaryDomain=yes

Offline mmccarn

  • *
  • 2,628
  • +10/-0
Re: DNS define domain without prefixes
« Reply #3 on: July 15, 2014, 12:45:48 PM »
[reply started before Stefano's comment]

The easy solution would be to put a "meta refresh" in the index.html file on your sme server that redirects from mysite.com to www.mysite.com:
Code: [Select]
<html>
  <head>
    <title>Redirect</title>
    <META http-equiv="refresh" content="0;URL=http://www.mysite.com">
  </head>
  <body bgcolor="#ffffff">
    <center>You are being redirected to <a href="http://www.mysite.com">http://www.mysite.com</a>
    </center>
  </body>
</html>

or use .htaccess on your SME to do a redirect to www.mysite.com:
a) enable AllowOverride for the ibay serving mysite.com locally, eg:
Code: [Select]
db accounts setprop Primary AllowOverride All
signal-event ibay-modify Primary
b) create .htaccess in the ibay html folder with the redirect code, eg:
Code: [Select]
cd /home/e-smith/files/ibays/Primary/html
echo '# This allows you to redirect your entire website to any other domain
Redirect 301 / http://www.mysite.com/' > .htaccess
chown www .htaccess


The hard way would involve lots of variables on your SME:

- don't create a local domain for mysite.com (would probably require that you create an 'alias' for each email user, if email is hosted on your SME server).
or
- customize the templates for tinydns (/etc/e-smith/templates/var/service/tinydns/root/data) to not create the default "A" record for mysite.com (you might need to create an "A" record with the external IP, or you might need to create a CNAME record...)
or
- create custom proxypass templates to make your SME server serve content from www.mysite.com when accessed at mysite.com (I don't think the default proxypass options built in to SME will work for the configuration you've described)
« Last Edit: July 15, 2014, 12:50:04 PM by mmccarn »

Offline cyberfido

  • 13
  • +0/-0
Re: DNS define domain without prefixes
« Reply #4 on: July 15, 2014, 01:03:25 PM »
Thank you very much, I tried the dirty and fast solution temporarily.
I'll see for the others in the future.
For other users who could read, the file I modified is
 /home/e-smith/files/ibays/Primary/html/index.htm