# How to use custom domain name for my gateway?

**URL:** <https://discourse.mozilla.org/t/how-to-use-custom-domain-name-for-my-gateway/45365>\
**Category:** WebThings\
**Created:** [September 20, 2019, 9:53am UTC](https://discourse.mozilla.org/t/how-to-use-custom-domain-name-for-my-gateway/45365 "2019-09-20T09:53:59Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![apvenkat](https://avatars.discourse-cdn.com/v4/letter/a/82dd89/32.png) [@apvenkat](https://discourse.mozilla.org/u/apvenkat)\
**Post date:** [September 20, 2019, 9:54am UTC](https://discourse.mozilla.org/t/how-to-use-custom-domain-name-for-my-gateway/45365/1 "2019-09-20T09:54:00Z")

</div>

Hi,  
Is there any document available to use custom domain names for my webthing gateway ?

---

<div class="post-metadata">

**Author:** ![mstegeman](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@mstegeman](https://discourse.mozilla.org/u/mstegeman)\
**Post date:** [September 20, 2019, 2:59pm UTC](https://discourse.mozilla.org/t/how-to-use-custom-domain-name-for-my-gateway/45365/2 "2019-09-20T14:59:59Z")

</div>

As in, use something other than the `*.mozilla-iot.org` domain? You’d have to do something like the following:

1. Set up your domain somewhere, pointing a DNS record to your IP address.
2. Forward ports 80 and 443 on your router to the gateway.
3. Set up certificates as desired. You can generate a self-signed cert with `tools/make-self-signed-cert.sh`, or you can use an ACME (Let’s Encrypt) client.

---

<div class="post-metadata">

**Author:** ![apvenkat](https://avatars.discourse-cdn.com/v4/letter/a/82dd89/32.png) [@apvenkat](https://discourse.mozilla.org/u/apvenkat)\
**Post date:** [September 21, 2019, 3:28am UTC](https://discourse.mozilla.org/t/how-to-use-custom-domain-name-for-my-gateway/45365/3 "2019-09-21T03:28:42Z")

</div>

Thanks @mstegeman

I agree with this method, but my router’s public ip is not static all the time as it keeps changing timely and I would like to do without port forwarding my router just like how mozilla’s subdomain is working, can you help me in this regard ?

---

<div class="post-metadata">

**Author:** ![mstegeman](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@mstegeman](https://discourse.mozilla.org/u/mstegeman)\
**Post date:** [September 21, 2019, 6:24pm UTC](https://discourse.mozilla.org/t/how-to-use-custom-domain-name-for-my-gateway/45365/4 "2019-09-21T18:24:43Z")

</div>

In that case, you can use a dynamic DNS client to keep your DNS record updated.

If you want to do what we’re doing, you can use [PageKite](https://pagekite.net/).

Another option would be:

1. host a VPN somewhere in the cloud with a static IP
2. point your DNS record to that host
3. forward traffic from that host, across the VPN to your gateway

---

<div class="post-metadata">

**Author:** ![apvenkat](https://avatars.discourse-cdn.com/v4/letter/a/82dd89/32.png) [@apvenkat](https://discourse.mozilla.org/u/apvenkat)\
**Post date:** [September 23, 2019, 7:54am UTC](https://discourse.mozilla.org/t/how-to-use-custom-domain-name-for-my-gateway/45365/5 "2019-09-23T07:54:23Z")

</div>

Thanks @mstegeman  
This is a good option to do for a single gateway.  
Let’s say If I have multiple gateways and I need sub-domain for each gateway, Can I point my wildcard DNS record to this VPN host ? How can I configure sub-domains for each of my gateways ? Please assist, thanks

---

<div class="post-metadata">

**Author:** ![mstegeman](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@mstegeman](https://discourse.mozilla.org/u/mstegeman)\
**Post date:** [September 23, 2019, 3:17pm UTC](https://discourse.mozilla.org/t/how-to-use-custom-domain-name-for-my-gateway/45365/6 "2019-09-23T15:17:30Z")

</div>

Yes, you could use a wildcard. You’d have to use a reverse proxy on the VPN host to route traffic to the appropriate tunnel, depending on the requested domain name.

For instance:

1. Set up VPN
2. Configure \*.example.com to point to your VPN host
3. Set up VPN clients on each gateway, have them auto-connect
4. Set up reverse proxy on your VPN host such that [gateway1.example.com](http://gateway1.example.com) gets routed to 10.0.0.2 (VPN tunnel 1), [gateway2.example.com](http://gateway2.example.com) gets routed to 10.0.0.3 (VPN tunnel 2), etc.

---

<div class="post-metadata">

**Author:** ![apvenkat](https://avatars.discourse-cdn.com/v4/letter/a/82dd89/32.png) [@apvenkat](https://discourse.mozilla.org/u/apvenkat)\
**Post date:** [September 26, 2019, 2:46pm UTC](https://discourse.mozilla.org/t/how-to-use-custom-domain-name-for-my-gateway/45365/7 "2019-09-26T14:46:28Z")

</div>

Thanks @mstegeman  
I am trying the registration server now to do the same thing using pagekite as i felt that is the best solution to use custom domain names. I have configured the nameservers, now I am bit uncler about nginx as I am new to it. What is this [api.xyz.com](http://api.xyz.com) in the nginx.conf file, do i need to create it or it will be auto created ? when i change my name severs like below  
[ns1.xyz.com](http://ns1.xyz.com) & [ns2.xyz.com](http://ns2.xyz.com)  
In godaddy, I can’t manage the DNS records and can’t add wildcard as the nameservers are not default from godaddy now. Could you please assist me ??

 ![image](https://us1.discourse-cdn.com/flex001/uploads/mozilla/original/3X/5/c/5ce280399865652ad9d3c430a268015859a58d90.png)

and also I am bit unclear about the email in the config.toml file, how can I set it ?? I was already using a e-mail server(MX) for this domain name, Please help…

 ![image](https://us1.discourse-cdn.com/flex001/uploads/mozilla/original/3X/0/2/029b7b00ae365fd3d9b763d6236abfa23bb8cea0.png)

Thanks,

---

<div class="post-metadata">

**Author:** ![mstegeman](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@mstegeman](https://discourse.mozilla.org/u/mstegeman)\
**Post date:** [September 26, 2019, 5:32pm UTC](https://discourse.mozilla.org/t/how-to-use-custom-domain-name-for-my-gateway/45365/8 "2019-09-26T17:32:09Z")

</div>

To be clear, I wasn’t suggesting that you run your own registration server. I was just saying that you could run PageKite yourself. You’d have to run the PageKite server in the cloud somewhere.

If you want to go the full registration server route…

The `api` subdomain is what the gateway talks to when setting up domains and such. Every other subdomain (except for `www`) is available for registration. nginx is just used as a reverse proxy for the registration server, primarily because we run several other services on the same host (such as the add-on and update proxies).

The registration server serves as the DNS resolver for the full domain, so your NS records _must_ be set up to point to it. If GoDaddy won’t let you do that, you’ll need to look at hosting your domain elsewhere.

---

<div class="post-metadata">

**Author:** ![apvenkat](https://avatars.discourse-cdn.com/v4/letter/a/82dd89/32.png) [@apvenkat](https://discourse.mozilla.org/u/apvenkat)\
**Post date:** [September 27, 2019, 9:28am UTC](https://discourse.mozilla.org/t/how-to-use-custom-domain-name-for-my-gateway/45365/9 "2019-09-27T09:28:15Z")

</div>

Thanks @mstegeman  
I have tried running pagekite in cloud and backend in my clients, it’s working perfect as i expected. Thanks for your help on time.
