1

I have created a website with a tiny administration panel that lets the owners change attributes about the site (primary color, background image, some content etc). Their changes are stored in a database.

What I want is to have multiple domains pointing to this site, and for the site to render the correct attributes (styles and content) based on the requests host header.

My thought was to create a reverse proxy front end server using NGINX with multiple server blocks pointing to the same application server (hosted on heroku). The application server again makes requests to the database server.

Then I would add a middleware to my application that checks the request host header, and looks up content in the database based on where the request is coming from.

My questions are:

  1. Is this a "normal" way to solve my problem? I am in the process of learning server setup and administration, so I don't know if this is a good / stable / scalable setup. Or if it will work at all. If not, how should I go about solving this?

  2. What is the limit of server blocks one NGINX instance can handle?

Many thanks.

  • Why do you want multiple `server` blocks? It sounds like one would suffice. – Michael Hampton Feb 22 '17 at 20:32
  • Ok. This might be wrong, but I was told that server blocks is what would let me point multiple different domains to one server. I want both www.example1.com and www.example2.com to point to my reverse proxy, and then be served the same site with different content / styles. – Olav Gundersen Feb 22 '17 at 20:37
  • You would use different `server` blocks to serve different domains _with different web applications_. If everything uses the same app, there's no point to separate `server` blocks. – Michael Hampton Feb 22 '17 at 20:44
  • I see, thanks. Would I need to define something at all in my server block to make it work with multiple domains, or would I just point the domains to my server and then handle the host lookup in my application code? Do I have to define what domains are "accepted"? – Olav Gundersen Feb 22 '17 at 20:49
  • See https://nginx.org/r/server_name – Michael Hampton Feb 22 '17 at 20:52

0 Answers0