6

I've always used name.dev for local development, but since Google Chrome 63 update, out December 2017, domains with .dev are in the preloaded HSTS list with a rule enforcing HTTPS, no workarounds.

IETF states a few reserved TLDs for development:

  1. TLDs for Testing, & Documentation Examples

    There is a need for top level domain (TLD) names that can be used for creating names which, without fear of conflicts with current or future actual TLD names in the global DNS, can be used for private
    testing of existing DNS related code, examples in documentation, DNS
    related experimentation, invalid DNS names, or other similar uses.

    For example, without guidance, a site might set up some local
    additional unused top level domains for testing of its local DNS code and configuration. Later, these TLDs might come into actual use on
    the global Internet. As a result, local attempts to reference the
    real data in these zones could be thwarted by the local test
    versions. Or test or example code might be written that accesses a
    TLD that is in use with the thought that the test code would only be
    run in a restricted testbed net or the example never actually run.
    Later, the test code could escape from the testbed or the example be
    actually coded and run on the Internet. Depending on the nature of
    the test or example, it might be best for it to be referencing a TLD
    permanently reserved for such purposes.

    To safely satisfy these needs, four domain names are reserved as
    listed and described below.

                .test
             .example
             .invalid
           .localhost
    

    ".test" is recommended for use in testing of current or new DNS related code.

    ".example" is recommended for use in documentation or as examples.

    ".invalid" is intended for use in online construction of domain names that are sure to be invalid and which it is obvious at a glance are invalid.

    The ".localhost" TLD has traditionally been statically defined in host DNS implementations as having an A record pointing to the loop back IP address and is reserved for such use. Any other use would conflict with widely deployed code which assumes this use.

But I was wondering if I could use something shorter. ###Is it ok to use only http://name for local websites?

I mean, only the project name, without TLD. Similar to the localhost "domain" itself.

1

2 Answers 2

2

Yes. Depending.

Client Side:

Most OSs allow for the editing of the hosts or hosts.txt file to associate a network name or domain name with an IP address. This is a client side option. You would do this on your desktop computer so that it knows how to address the request packet. Here is more detailed information including example settings.

https://en.wikipedia.org/wiki/Hosts_(file)

You can configure another name for localhost, however, just adding a name will allow you to access the web server from a client on the same network. You would have to make this entry for all of the computers you expect to use in this manner. Assuming you are a developer, this is often the case where the client and web server are two different computers. Do not expect this to always work through a firewall over the Internet. It can, however, some firewalls may not allow it.

You can set your computer to use a search domain to append a domain name to the short name you provide. There is an excellent answer here for this. https://serverfault.com/questions/23397/resolving-host-names-to-their-domain-name-in-an-internal-bind-domain/23401#23401 This also requires a configuration change per computer that you intend to use in this manner.

Server Side:

The problem begins with the web server. The assumption is that the web server can handle the name. Certainly, myawesomesite.test can easily be configured as a site. However, myawesomesite without the TLD may not be configurable. There are ways around this.

For example, with Apache, when a request packet comes in, Apache will try and match it with a configured site. If it cannot, it will serve the first site created. Often, this will be configured as a catch-all site intended to capture invalid requests and IP address only requests. This is not always done. However, the first site created can always be used for any site that cannot be properly configured by name or IP address only sites. Other web servers do this as well.

Certainly, any Apache server can be reconfigured to add a catch-all site where one does not exist. I cover some configuration examples here where a catch-all site exists. Virtualhost config: routing and wildcard usage Always take this task on with caution. You will likely have to experiment if you are not familiar with Apache configuration. And as always, Apache will have to be restarted before the configuration changes are taken in consideration.

As @StephenOstermiller points out in the comments, any existing site can simply have 'ServerAlias' set to an alternative name such as myawesomesite.test. He also points out that a shorter name can be used. I have not ever tried this. It costs relatively nothing to try it.

IIS should be able to use a NetBios name. If you are using a Windows network, you can look into this and it should do what you want.

For other web servers, I cannot give advice. Sorry. However, there is likely an answer if you research.

15
  • 2
    Right below ServerName myapp.example.com you can put ServerAlias myapp, ServerAlias myapp.local and ServerAlias myapp.test which will allow that virtual host either way that it is specified as long as you have a local way of mapping those via DNS. Dec 12, 2017 at 18:40
  • @StephenOstermiller Great input! I have never fooled around with site names less than a domain name with the exception of IIS 1000 years ago. IIS will, of course, use a Windows NETBIOS name. Cheers!!
    – closetnoc
    Dec 12, 2017 at 19:08
  • @StephenOstermiller Added to answer. Please let me know how I can further improve this answer! Cheers!!
    – closetnoc
    Dec 12, 2017 at 19:17
  • I'd include something about the DNS settings for "search domain". If you have control over your local DHCP server, you can have it give your chosen fake TLD as the default for all DHCP connected clients. That way you don't have to modify /etc/hosts on every computer. Dec 12, 2017 at 19:20
  • 1
    .DEV is indeed now a true TLD, see iana.org/domains/root/db/dev.html so even without changes in Google product you will run into problems if you use fake names in this TLD, like in any other TLD. Dec 15, 2017 at 2:23
1

The domain name in the URL http://name/ does have a TLD, or rather: it consists only of a TLD (name). It would be http://name./ as FQDN, but the variant without the . typically works in browsers, too.

While it’s uncommon that TLD owners make the TLD itself resolvable, some do. For example, this was the case with http://to/, and it still is the case with http://dk/.

As of posting this answer, you can test it yourself: http://dk/ (currently redirects to a third-level domain name).

So is it "okay" to use them?

  • No, if you want to prevent the possibility of getting surprised again in the future. The project name you choose could become a TLD, and this TLD could itself become resolvable. To be safe, stick with the reserved TLDs.

  • Yes, if you can live with this risk. But if you use non-reserved TLDs, it might be a good idea to configure your system in such a way that DNS requests to these TLDs won’t go out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.