1

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: example.com/vhost1/some/path and rewrite them to: vhost1.example.com/some/path

Can I do that without configuring DNS for vhost1.example.com?

Do I need to add vhost1.example.com to the hosts name on the machine?

Thanks

0

4 Answers 4

2

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

10.87.42.22  project1.example.com

And then try loading the URL in your browser.

1

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

1
  • 1
    +1, we do this way in our development environment and live happy since 2 years. *.deveoper-name.internal.lan.
    – drAlberT
    Oct 14, 2009 at 15:46
0

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 example.com to vhost.example.com instead.

0

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).

You must log in to answer this question.

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