Apache-2.2

在 Apache2 上設置 IPv6

  • October 26, 2014

目前我有以下內容的“ports.conf”:

NameVirtualHost *:80
Listen 80

<IfModule mod_ssl.c>
   Listen 443
   NameVirtualHost *:443
</IfModule>

<IfModule mod_gnutls.c>
   Listen 443
</IfModule>

因此,要添加 IPv6,我必須將其更改為:

NameVirtualHost 91.64.99.215:80
Listen 91.64.99.215:80

NameVirtualHost [2a01:4f8:140:54e4::3]:80
Listen [2a01:4f8:140:54e4::3]:80

<IfModule mod_ssl.c>
   Listen 443
   NameVirtualHost 91.64.99.215:443
   NameVirtualHost [2a01:4f8:140:54e4::3]:443
</IfModule>

<IfModule mod_gnutls.c>
   Listen 91.64.99.215:443
   Listen [2a01:4f8:140:54e4::3]:443
</IfModule>

它是否正確?

我擔心的是,如果我這樣做,所有虛擬主機都設置為

<VirtualHost *:80>
    ServerName www.domain.tld
    ServerAlias domain.tld
    DocumentRoot /www/domain
</VirtualHost>

會發狂。如果不是這種情況,做

<VirtualHost *:80 [*]:80>
    ServerName www.domain.tld
    ServerAlias domain.tld
    DocumentRoot /www/domain
</VirtualHost>

還應該通過 IPv6 使域可用嗎?

我在這裡有點困惑,無法充分利用現有的“範例”任何幫助將不勝感激。

您只需將Listen指令更改為:

Listen [::]:80
Listen [::]:443

而你的

NameVirtualHost *:80
<VirtualHost *:80>

保持不變。

注意:netstat -tln將僅在tcp6/上顯示 apache 偵聽:::80;這是正常的(它也會像以前一樣響應 IPv4)

引用自:https://serverfault.com/questions/624184