Mercurial > hg > nginx-site
comparison xml/en/docs/http/ngx_http_core_module.xml @ 70:272d99af0c15
The "server_name" directive:
- has changed the default value from hostname to "",
- accepts the special argument "$hostname".
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Sun, 09 Oct 2011 21:19:52 +0000 |
parents | 935beaa561b3 |
children | 0987079ad08f |
comparison
equal
deleted
inserted
replaced
69:935beaa561b3 | 70:272d99af0c15 |
---|---|
1641 </directive> | 1641 </directive> |
1642 | 1642 |
1643 | 1643 |
1644 <directive name="server_name"> | 1644 <directive name="server_name"> |
1645 <syntax>server_name <argument>name</argument> ...</syntax> | 1645 <syntax>server_name <argument>name</argument> ...</syntax> |
1646 <default>server_name hostname</default> | 1646 <default>server_name ""</default> |
1647 <context>server</context> | 1647 <context>server</context> |
1648 | 1648 |
1649 <para> | 1649 <para> |
1650 Sets names of the virtual server, for example: | 1650 Sets names of the virtual server, for example: |
1651 <example> | 1651 <example> |
1654 } | 1654 } |
1655 </example> | 1655 </example> |
1656 </para> | 1656 </para> |
1657 | 1657 |
1658 <para> | 1658 <para> |
1659 The first name becomes a primary server name. | 1659 The first name becomes the primary server name. |
1660 By default, the machine's hostname is used. | |
1661 Server names can include an asterisk (<dq><code>*</code></dq>) | 1660 Server names can include an asterisk (<dq><code>*</code></dq>) |
1662 to replace the first or last part of a name: | 1661 to replace the first or last part of a name: |
1663 <example> | 1662 <example> |
1664 server { | 1663 server { |
1665 server_name example.com *.example.com www.example.*; | 1664 server_name example.com *.example.com www.example.*; |
1672 <example> | 1671 <example> |
1673 server { | 1672 server { |
1674 server_name .example.com; | 1673 server_name .example.com; |
1675 } | 1674 } |
1676 </example> | 1675 </example> |
1676 </para> | |
1677 | |
1678 <para> | |
1679 If the argument equals “<var>$hostname</var>” (0.9.4), the | |
1680 machine's hostname is substituted. | |
1677 </para> | 1681 </para> |
1678 | 1682 |
1679 <para> | 1683 <para> |
1680 It is also possible to use regular expressions in server names, | 1684 It is also possible to use regular expressions in server names, |
1681 prepending the name with a tilde (<dq><code>~</code></dq>): | 1685 prepending the name with a tilde (<dq><code>~</code></dq>): |
1707 } | 1711 } |
1708 </example> | 1712 </example> |
1709 </para> | 1713 </para> |
1710 | 1714 |
1711 <para> | 1715 <para> |
1712 Starting from version 0.8.25, named captures in regular expressions create | 1716 Named captures in regular expressions create variables (0.8.25) |
1713 variables that can later be used in other directives: | 1717 that can later be used in other directives: |
1714 <example> | 1718 <example> |
1715 server { | 1719 server { |
1716 server_name ~^(www\.)?(?<domain>.+)$; | 1720 server_name ~^(www\.)?(?<domain>.+)$; |
1717 | 1721 |
1718 location / { | 1722 location / { |
1729 } | 1733 } |
1730 </example> | 1734 </example> |
1731 </para> | 1735 </para> |
1732 | 1736 |
1733 <para> | 1737 <para> |
1734 Starting from version 0.7.11, it is possible to specify an empty name: | 1738 It is also possible to specify an empty server name (0.7.11): |
1735 <example> | 1739 <example> |
1736 server { | 1740 server { |
1737 server_name www.example.com ""; | 1741 server_name www.example.com ""; |
1738 } | 1742 } |
1739 </example> | 1743 </example> |
1740 It allows this server to process requests without the <header>Host</header> | 1744 It allows this server to process requests without the <header>Host</header> |
1741 header, instead of the default server for the given address:port pair. | 1745 header, instead of the default server for the given address:port pair. |
1746 This is the default setting. | |
1747 <note> | |
1748 Before 0.8.48, the machine's hostname was used by default. | |
1749 </note> | |
1742 </para> | 1750 </para> |
1743 | 1751 |
1744 <para> | 1752 <para> |
1745 The name checking order is as follows: | 1753 The name checking order is as follows: |
1746 <list type="enum"> | 1754 <list type="enum"> |