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'm developing a web app where users will have their own sub-domain to login to and use the application. I'm running wordpress for the main website to manage the public / front end. Our application is developed in zend framework. The zf project is currently in a subfolder on the main server.

I'd like to place the zend framework project onto another server (different IP) and keep it separate from the the wordpress front end site.

The zf application server will run nginx. I'm not sure how to setup a server to run strictly sub domains. Setting up the virtual hosts in the configuration file is no problem. To give the users But what about the main default configuration file? How would that be configured since the top level domain is technically another server (wordpress) on another IP?

share|improve this question
up vote 2 down vote accepted

you just dont setup the main domain as an nginx vhost on the subdomain server and leave the dns pointing at the old server.

you then setup vhosts for the subdomains (or catch all subdomains depending on your application) and point dns at your subdomain server

so i'm guessing dns will look something like this: A 123.456.789.123 A 123.456.789.123 A 123.456.789.124 A 123.456.789.124 etc ...

its that simple, the main default config file doesnt need to be edited, in fact you could remove it if you wanted (although i would suggest leaving it and setting its server name to localhost and as default so that any subdomains not listened to get a default page :)

share|improve this answer
I thought I would need a default site enabled. Another question in regards to DNS. If I used a wildcard A record *, for sub domains that don't exist can I do a Redirect for 404's to a custom page rather than have them resolve to whatever they would possibly not sure. But rather than resolving send requests to a custom 404? – Anagio Nov 20 '11 at 9:23
as long as the wildcard vhost was last read config file or you did that as part of a generic default vhost that wont be an issue at all, because it will look for a match first before reverting to the default vhost - a default vhost is not required, but if its not specified you wont get consistent behaviour on non matching server names – anthonysomerset Nov 21 '11 at 8:36

If I understood your issue correctly, you can do it via DNS if you are going to have a few user base. Still having DNS changes for every user is cumbersome and involves time for propagation. If the user base is huge, then you can choose a format & then redirect the requests accordingly to the remote IP using a PHP script.

share|improve this answer
Yes we'll have a large user base so new A records for every subdomain isn't really an option. I'm thinking of using a wildcard on my main domain and would like to catch 404s for subdomains that dont have a virtual host setup and redirect them. I prefer not redirect visitors and get them to their page the first time. – Anagio Nov 20 '11 at 9:26

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.