Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

if I set x.domain.com and y.domain.com to the same ip address, Does it mean Nginx couldn't tell the differences between x.domain.com and y.domain.com?

Is it impossible to map x.domain.com and y.domain in the server directive in the server context to the different folder?

I also want to learn more about how the computer network work? Anyone could give me some resources?

share|improve this question
    
That really looks like two different questions. I can't help with the exact config, but for the first two parts, virtualhosts or its equivalent would do the trick –  Journeyman Geek Dec 17 '11 at 9:46
    
It's actually three different questions. The last is "I want to learn about networking. What should I read?" and would be far better off as a proper standalone question (although I have my doubts that it would survive, even though a Community Wiki bibliography would surely be a help to people). –  JdeBP Dec 17 '11 at 19:29
add comment

2 Answers

if I set x.domain.com and y.domain.com to the same ip address, Does it mean Nginx couldn't tell the differences between x.domain.com and y.domain.com?

Is it impossible to map x.domain.com and y.domain in the server directive in the server context to the different folder?

It can; all HTTP clients send a Host header along with the request. For example,

GET /page.html HTTP/1.1
Host: x.domain.com
User-Agent: Mozilla/5.0

This is very widely used; see virtual hosting. For nginx configuration, see VirtualHostExample on nginx wiki.

share|improve this answer
    
Thanks very clear answer! –  yozloy Dec 18 '11 at 10:19
add comment

Multiple (sub-)domains like x.domain.com and y.domain.com on the same ip adress are nothing special.

It's called "named based virtual hosting", and you can find more informations on wikipedia or in the nginx documentation:

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.