0

I have purchased a domain from the registrar (godaddy) - for example mycompany.com

When this url is entered in the browser, the browser will direct the request to the configured IP address (which is a nginx reverse proxy server that is sitting in my company onpremise).

We have developed couple of api's for various departments which we want to export via the url. There are 2 options:

  1. mycompany.com/api/departmentA, mycompany.com/api/departmentB, ...

  2. api.departmentA.mycompany.com, api.depoartmentB.mycompany.com

I know that the 1st option does not need any change at the registrar (godaddy) or the server (nginx).

Suppose I choose the 2nd option, then I know that I need to make nginx config changes so that - based on the url the request will be directed by nginx to the appropriate server. This question is to ask - Does domain registrar (godaddy) require any configuration to allow subdomains to be routed to the same server as that configured for the domain? For example do I need to add a CNAME record for each sub domain? or does the godaddy automatically redirect any subdomain to the IP of the domain?

1 Answer 1

1

This might be more appropriate for webmasters.stackexchange.com. That said -

  1. The first option MAY need changes on the NGINX server depending on the nature of the API and layout of the filesystem.

  2. You would need to set up subdomains on the DNS (which I suspect is at the registrar in your case, but doesn't need to be) to point to your NGINX IP.

One way to do this would be to use a wildcard subdomain (ie "*") This is fairly trivial if you have access to the DNS. You would be better off with an A record then a CNAME in this case. (CNAMES don't work how people think they do). Alternatively you could set up each individual record with a CNAME.

For option 2, you will also need to get a wildcard cert - which would be difficult to do through Lets Encrypt, so you would be purchasing it and renewing it every year or so.

4
  • About Lets encrypt - can I not create one certificate per sub domain configured in nginx?
    – variable
    Commented May 20, 2022 at 5:50
  • Yes you can do that.
    – davidgo
    Commented May 20, 2022 at 8:34
  • I didn't get why you say which would be difficult to do through Lets Encrypt
    – variable
    Commented May 20, 2022 at 8:42
  • Because you started off by asking about "redirecting any subdomain to the IP of a domain", which usually implies handling a large number of subdomains. When working "at scale" you would not typically generate individual certificates.
    – davidgo
    Commented May 20, 2022 at 10:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .