Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to serve a large number of websites on the same machine. I'll need to be able to add and remove websites dynamically.

Internally, the web server needs to think that the request arrived from a vhost.

Is it possible to use nginx in the front that will handle requests in the form: and rewrite them to:

Can I do that without configuring DNS for

Do I need to add to the hosts name on the machine?


share|improve this question

migrated from Oct 14 '09 at 12:38

This question came from our site for professional and enthusiast programmers.

If you want to test client connections to the vhost, add it to the /etc/hosts file (or equiv on Windows) on the client:

And then try loading the URL in your browser.

share|improve this answer

You can add wildcard domain * (this is possible in BIND, don't know about other DNS servers) and setup nginx vhosts, This way you don't have to update DNS for each added subdomain!

share|improve this answer
+1, we do this way in our development environment and live happy since 2 years. *.deveoper-name.internal.lan. – drAlberT Oct 14 '09 at 15:46

I'm not quite sure what it is that you are trying to achieve. If it is merely an internal re-mapping, you should be able to use a number of non-DNS related methods to change it. The only reason that you may need to change the DNS records is if this involves redirecting clients from to instead.

share|improve this answer

I run djbDNS on my internal network (and have done previously for more publicly accessible sites) with a given .TLD and wildcard - so *.localtest would resolves to a given IP, which Apache or thttpd will pick up (with Apache's VirtualDocumentRoot). You would be able to do much the same with nginx as well (serve a site based on the HTTP_HOST).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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