虽然端口443未被占用,但Apache无法绑定SSL的443地址。

3

我最近安装了启用openssl 1.0.2j的Apache 2.4.20版本。

在更新了httpd.conf和httpd-ssl.conf文件,并尝试在监听443端口时启动Apache后,出现了以下错误:

(13)Permission denied: -----: make_sock: could not bind to address [::]:443
(13)Permission denied: -----: make_sock: could not bind to address 0.0.0.0:443
no listening sockets available, shutting down

以下是配置文件内容:

这是我的配置:

httpd.conf:

Listen 51000
#Listen 443
#Secure (SSL/TLS) connections
Include conf/extra/httpd-ssl.conf

httpd-ssl.conf

Listen 443

如果我在httpd-ssl.conf文件中注释掉这一行,我的Apache就会正常启动:
attempting to start apache
done

然而,每次使用它时我都会遇到套接字错误。 我以root身份运行了以下命令:
netstat -tlpn | grep :443

没有返回任何内容。

lsof -i tcp:443

什么都没返回。

我在某个地方读到只有root用户才能绑定到1024以下的地址,但我不确定这个说法是否正确。Apache没有以root身份运行 - 这会是问题吗?


我有同样的问题。如果您无法实际指定要侦听的HTTPS端口和IP地址,那么在ssl.conf中甚至拥有“侦听”选项似乎有点愚蠢。奇怪的是,在我的情况下,如果我注释掉“侦听”选项,那么Apache默认仍会侦听*:443,但不是特定的IP地址。 - Leslie Krause
2个回答

3

谢谢你的回答 - 当我早些时候读到那篇文章时,我就担心会是这样。我会研究一下解决方法,看看是否适用于我的情况。 - notagoodcoder

0
如果您正在使用docker-compose,
当我们使用非root容器(如bitnami官方镜像)时,会出现这种情况。
当需要与主机网络绑定时,我们使用user:root和network_mode:host。
  apache:
    image: bitnami/apache:2.4
    container_name: "apache"
    ports:
      - 80:80
    network_mode: host
    privileged: true
    user: root
    environment:
      DOCKER_HOST: "unix:///var/run/docker.sock"
    env_file:
      - .env
    volumes:
      - ./setup/apache/httpd.conf:/opt/bitnami/apache/conf/httpd.conf

希望对你有所帮助!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接