Access antlets by Domain Name

If you want to configure antsle so that the world can access your antlets by domain name, e.g. myawesomesite.com, then this page will guide you through the steps to do that.

Before you start, you need to setup port forwarding in your router. That step is only needed once. You don’t need to do that for every new domain name and/or antlet. You can skip port forwarding altogether if you (a) only access antlets from your local LAN/WiFi or (b) you’re using a tunnelling solution.

After you’ve setup port forwarding (once), it’s a three-step process:

  1. Get a domain name.
  2. Set the A record.
  3. Connect domain with antlet.
Here are our instructions for each of these steps:

1 Get a domain name

You can register your domain name, e.g. mysite.com, through any domain registrar of your liking, e.g. godaddy.com.

2 Set the A record

Set the A record of your new domain to the IP address of your home or office Internet connection. To check your IP address, just go to checkip.dyndns.org in your browser. Copy that IP address to your clipboard. The go to the portal of the registrar that you bought your domain from. In case you bought it from GoDaddy, see here for help.

Go to “DNS settings” and find where to set the A record. Set it to the IP address that you found out earlier.

After you’ve changed the A record, please allow up to 48 hours to let that change propagate through all DNS server of the Internet. In many cases you will be able to use the new domain after two hours or so. It’s a good idea to restart your router a few hours after you’ve updated the A record, so that the router will pull the latest DNS information from the Internet.

Please keep in mind that this step works best when you have a static IP address from your ISP. Alternatively, you can use a dynamic DNS provider.

3 Connect domain with antlet

After steps 1 and 2 are done, any traffic for your domain will arrive in your router. The port forwarding in your router will send it onwards to your antsle. The last step now is to tell antsle to connect the domain name to the antlet of your choice. In order to achieve that, follow these steps:

Login to your antsle via ssh root@myantsle.local.

Enter this command: cd /etc/nginx/virtualhosts.

Then enter this command: nano mysite.com.conf. Make sure to use the name of your own domain, not mysite.com!

Paste this text into the file:

server {
    server_name www.mysite.com;
    rewrite ^ $scheme://mysite.com$request_uri redirect;
}
server {
    listen 80;
    server_name mysite.com;
    root /var/www;
    location / {
        proxy_read_timeout 300;
        proxy_connect_timeout 300;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Protocol $scheme;
        proxy_set_header X-Forwarded-Ssl off;
        proxy_set_header X-Url-Scheme $scheme;
        proxy_set_header X-Frame-Options SAMEORIGIN;
        proxy_pass http://10.1.1.10;
    }
}

Make sure to replace mysite.com with the correct name of your own domain, and replace 10.1.1.10 with the IP address of the antlet you want to connect this domain name to.

The intent of the first 'server { ... }' block is to redirect URLs prefixed with www to a URL without it, the second 'server { ... }' block - 'www.mysite.com' will redirect to 'mysite.com'. Many people always type a 'www' in the URL but is not part of many domain names.

If your domain name is prefixed with www or you are using some other subdomain like yoyo.mysite.com, you can delete the first 'server { ... }' block

server {
    server_name www.mysite.com;
    rewrite ^ $scheme://mysite.com$request_uri redirect;
}

and edit the second 'server { ... }' block with the full domain name.

server {
    listen 80;
    server_name yoyo.mysite.com;
    root /var/www;
    location / {
        proxy_read_timeout 300;
    ...
    }
}

Press Ctrl-X in nano, enter Y for Yes when asked if you want to save, and hit Enter for the file name.

Finally, enter this command: service nginx restart

You’re ready to go now. From anywhere in the world, mysite.com will lead you directly to your antlet now.