Ipv6

在 debian 上,使用 80 埠的 lighttpd apache2,lighttpd 拋出:address already use 錯誤

  • October 25, 2013

前幾天我買了 linode(linode.com) 伺服器。我一直在嘗試在同一個埠上執行 lighttpd 和 apache2,將 lighttpd 用於靜態文件。由於 linode 只提供一個 ipv4 地址,我嘗試在 ipv6 地址上綁定 lighttpd。那就是我每次都遇到相同錯誤的地方:無法綁定到埠

$$ ipv6 $$80 地址已在使用中。我試過綁定ipv4地址。一切正常。請幫助我,這讓我在過去的兩天裡發瘋了。 我的 lighttpd.conf 文件:(ipv6 地址不正確)

server.modules = (
   "mod_access",
   "mod_alias",
   "mod_compress",
   "mod_redirect",
#       "mod_rewrite",
)

server.document-root        = "/var/www"
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log"
server.pid-file             = "/var/run/lighttpd.pid"
server.username             = "www-data"
server.groupname            = "www-data"
server.port                 = 80
server.bind         = "2600:3c02::0000"
server.use-ipv6         = "enable"
#server.pid-file            = "/var/run/lighttpd.pid"


index-file.names            = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny             = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

compress.cache-dir          = "/var/cache/lighttpd/compress/"
compress.filetype           = ( "application/javascript", "text/css", "text/html", "text/plain" )

# default listening port for IPv6 falls back to the IPv4 port
#include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"


### ipv6 ###
$SERVER["socket"] == "[2600:3c02::0000]:80" {
#   accesslog.filename  = "var/log/lighttpd/ipv6/access.log"    
#   server.document-root = "/var/www/"
#   server.error-handler-404 = "/index.php?error=404"
}

和錯誤消息:無法綁定到埠,2600:3c02::0000 地址已在使用中。

你綁定[2600:3c02::0000]:80

server.port                 = 80
server.bind         = "2600:3c02::0000"

$SERVER["socket"] == "[2600:3c02::0000]:80" {
...
}

這意味著您將兩次綁定到同一個地址。刪除$SERVER["socket"]塊,你應該沒問題。

編輯:這樣你就得到了你所要求的;但我懷疑你的“設置”通常是一個好主意;正如 Halfgaar 指出的那樣,一個網路伺服器必須代理另一個;通常提供靜態文件的伺服器應該是公共可見的一個,代理到另一個隱藏的)

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