2013-05-01 4 views
2

와일드 카드 DNS 항목이 있으므로 * .mydomain.tld가 내 서버로 연결됩니다. 내가 nginx를 를 사용하고 나는 2 개의 conf 파일 제목이 :nginx catchall conf 파일이 모두 catch하지 않습니다

  • 기본
  • myconf.conf

내 conf의 파일는 다음과 같이 :

기본 :

server { 
    listen 80; 
    listen [::]:80 default_server ipv6only=on; 

    root /var/www/website; 
    index index.html index.htm; 

    server_name _; 

    location/{ 
     # First attempt to serve request as file, then 
     # as directory, then fall back to displaying a 404. 
     try_files $uri $uri/ /index.html; 
    } 
} 

myconf.conf :

server { 
    listen 80; 
    #listen [::]:80 default_server ipv6only=on; 

    root /home/me/www/website; 
    index index.php index.html index.htm; 

    # Make site accessible from http://localhost/ 
    # orig # server_name localhost; 
    server_name me.mydomain.tld; 

    access_log /home/me/logs/me.mydomain.tld.access.log; 
    error_log /home/me/logs/me.mydomain.tld.error.log warn; 

    location/{ 
     try_files $uri $uri/ $uri.php?$args; 
    } 
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 
    # 
    location ~ \.php$ { 
     try_files $uri =404; 
     fastcgi_split_path_info ^(.+\.php)(/.+)$; 

     # With php5-fpm: 
     fastcgi_pass unix:/var/run/php5-fpm.sock; 
     fastcgi_index index.php; 
     include fastcgi_params; 
    } 
} 

다음과 같이 도메인을 탐색 할 때로드되는 conf 파일입니다.

  • me.mydomain.tld로드 최대 루트 디렉토리 myconf.conf에 정의
  • mydomain.tld로드 업 루트 디렉토리는 기본적으로 정의
  • anything.mydomain.tld로드 최대 루트 디렉토리를 myconf.conf에 정의

기본값이 잘못되었습니다. anything.mydomain.tld는 기본 conf 파일의 루트 디렉토리를로드해야합니다.

답변

4

기본 설정 파일에서 을 모두 listen 줄로 지정해야합니다. (즉 의도 인 경우)

server { 
    listen 80 default_server; 
    listen [::]:80 default_server ipv6only=on; 

    root /var/www/website; 
    index index.html index.htm; 

    #server_name _; 

    location/{ 
     # First attempt to serve request as file, then 
     # as directory, then fall back to displaying a 404. 
     try_files $uri $uri/ /index.html; 
    } 
} 

당신이 server_name에 사용하는 밑줄 실제로 와일드 카드되지 않습니다 : 또한, 당신은 server_name 줄을 제거해야합니다. nginx Server Names 문서에서 :

이 이름에는 특별한 것이 하나도없고 실제 이름과 교차하지 않는 수많은 무효 도메인 이름 중 하나 일뿐입니다. "-"및 "! @ #"과 같은 다른 잘못된 이름이 똑같이 사용될 수 있습니다.

관련 문제