Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

migrated from stackoverflow.com Oct 14 '09 at 12:38

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

add comment

4 Answers

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.

share|improve this answer
add comment

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!

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

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.

share|improve this answer
add comment

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
add comment

Your Answer

 
discard

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.