2016-05-01 22 views
1

たとえば、ドメインexample.comを持っていると、ユーザーがサインアップするときにWebアプリケーションによってサブドメインが作成されます。ワイルドカードドメイン(Nginx)から特定のサブドメインを除外する方法

  • foo.example.com同じサイトを指します
  • bar.example.com、は、同じサイトに

を指すようになります。しかし、私はテスト環境を作成したいです例えばdemo.example.comこれは別のプロジェクトを指します。ユーザーがサインアップするとき、それはあります

  • foo.demo.example.com
  • bar.demo.example.com

私が持っている現在、どのような

| Name   | Type | Value   | 
|----------------|-------|-----------------| 
| example.com. | A  | 123.123.123.123 | 
| *.example.com. | CNAME | example.com. | 

と私のnginxの設定

server { 
    listen 80; 

    root /var/www/example.com/public; 
    index index.html index.htm index.php; 
    server_name example.com *.example.com; 

    location/{ 
     try_files $uri $uri/ /index.php?$query_string; 
    } 
    location ~ \.php$ { 
     try_files $uri /index.php =404; 
     fastcgi_split_path_info ^(.+\.php)(/.+)$; 
     fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; 
     fastcgi_index index.php; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     include fastcgi_params; 
    } 

    location ~ /\.ht { 
     deny all; 
    } 
} 

テスト環境用に1を作成するにはどうすればよいですか?

答えて

2

server_nameとしてサブドメインfqdnを持つ新しいサーバーブロックを作成する必要があります.nginxはこの優先順位に従います。

  1. 正確な名前
  2. 最長ワイルドカード名アスタリスクで始まる、例えば"* .example.org"
  3. アスタリスクで終わる最長のワイルドカード名。 「メール。*」(設定ファイル内の出現順に)正規表現にマッチ
  4. まず

詳細情報については:http://nginx.org/en/docs/http/server_names.html

関連する問題