2012-03-31 8 views
1

Ich benutze Nginx + Einhorn in Linode.konfigurieren Subdomain Nginx mit Einhorn

Das ist mein nginx.conf

upstream unicorn { 
    server unix:/tmp/unicorn.mydomain.sock fail_timeout=0; 
} 
server { 
    listen 80 default; 
    server_name mydomain.com; 
    keepalive_timeout 5; 

    root /home/hyperrjas/mydomain.com/current/public; 

    location/{ 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    # this is required for HTTPS: 
    # proxy_set_header X-Forwarded-Proto https; 
    proxy_set_header Host $http_host; 
    proxy_redirect off; 
    proxy_pass http://unicorn; 
    } 

     location ~ ^/(assets)/ { 
           root /home/hyperrjas/mydomain.com/current/public; 
           gzip_static on; # to serve pre-gzipped version 
           expires max; 
           add_header Cache-Control public; 
           } 

    error_page 500 502 503 504 /500.html; 
} 

Ich möchte 4 Subdomains hinzuzufügen:

imagescdn1.mydomain.com 
imagescdn2.mydomain.com 
imagescdn3.mydomain.com 
imagescdn4.mydomain.com 

Wie kann ich es tun?

Antwort

3

Sie sollten regex für server_name Richtlinie, das heißt so etwas wie folgt verwenden:

server { 
    server_name mydomain.com ~^imagescdn\d+\.mydomain\.com$; 
} 

auf Original-Dokumentation finden here und here für weitere Informationen.

+0

wir danken Ihnen, es funktioniert gut: D Vielen Dank – hyperrjas

+0

Ja, Sie könnten nur www.mydomain.com hinzufügen, um die Liste: server_name mydomain.com www.mydomain.com ~^imagescdn \ d + \. Mydomain \ .com $; – BluesRockAddict