2017-07-28 3 views

答えて

0

いいえ、それはどちらかのコンテキストでは必要ありません - nginxのは、自動的にの世話をします末尾のドットは、$host variableのコンテキストと、server_name directiveのコンテキストの両方であり、余分なドット(要求に存在する場合)を$http_host variableに残します。

は、私はそれがhttp/ngx_http_request.c#ngx_http_validate_hostで実装されていると信じて:

1925 if (dot_pos == host_len - 1) { 
1926  host_len--; 
1927 } 
それは、次の最小限の設定を確認することができます

server { 
    listen [::]:7325; 
    server_name ~^(\w*)\.?(example\.com\.?)$; 
    return 200 C:$2\tH:$host\tHH:$http_host\tSN:$server_name\n; 
} 

nginx/1.2.1に対して次のテストを実行:

%printf 'GET/HTTP/1.0\nHost: head.example.com.\n\n' | nc localhost 7325 | fgrep example 
C:example.com H:head.example.com HH:head.example.com. SN:~^(\w*)\.?(example\.com\.?)$ 
% 
%printf 'GET http://line.example.com./ HTTP/1.0\n\n' | nc localhost 7325 | fgrep example 
C:example.com H:line.example.com HH: SN:~^(\w*)\.?(example\.com\.?)$ 
% 
%printf 'GET http://line.example.com./ HTTP/1.0\nHost: head.example.com.\n\n' | nc localhost 7325 | fgrep example 
C:example.com H:line.example.com HH:head.example.com. SN:~^(\w*)\.?(example\.com\.?)$ 
% 

注意してください、内部からの正規表現のキャプチャserver_nameディレクティブまたは$host変数には、末尾にドットがあります。したがって、上記の文脈でそれを説明するのは無意味です。

関連する問題