nginx

2013-10-30 12 views
5

में किसी सर्वर के लिए यूआरएल पथ मैप करना /var/www/siteA पर स्थित वर्चुअल सर्वर पर staging.example.com/siteA के यूआरआई को कैसे मैप कर सकता हूं?nginx

मुख्य प्रतिबंध यह है कि मैं साइट ए के लिए सबडोमेन नहीं बनाना चाहता हूं। Nginx.conf के सभी उदाहरण मैंने अब तक मैपिंग करने के लिए सबडोमेन रखने पर भरोसा किया है।

धन्यवाद

उत्तर

12

आप इस प्रकार का location ब्लॉक के भीतर root directive उपयोग कर सकते हैं,:

server { 
    server_name staging.example.com; 
    root /some/other/location; 
    location /siteA/ { 
     root /var/www/; 
    } 
} 

फिर http://staging.example.com/foo.txt/some/other/location/foo.txt को अंक है, जबकि http://staging.example.com/siteA/foo.txt अंक /var/www/siteA/foo.txt करने के लिए।

ध्यान दें कि siteA निर्देशिका अभी भी फाइल सिस्टम पर मौजूद होने की उम्मीद है। यदि आप http://staging.example.com/siteA/foo.txt को /var/www/foo.txt पर इंगित करना चाहते हैं, तो आपको alias directive:

location /siteA/ { 
    alias /var/www; 
} 
का उपयोग करना होगा

 संबंधित मुद्दे