[英]Apache cannot bind :443 address for SSL even though port 443 is unused
I recently installed Apache 2.4.20 with SSL enabled using openssl 1.0.2j.我最近使用 openssl 1.0.2j 安装了启用 SSL 的 Apache 2.4.20。
After updating the httpd.conf and httpd-ssl.conf files and trying to start Apache while listening to port 443, I get the following error:更新 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
Here is what I have for config:这是我的配置:
httpd.conf: httpd.conf:
Listen 51000
#Listen 443
#Secure (SSL/TLS) connections
Include conf/extra/httpd-ssl.conf
httpd-ssl.conf httpd-ssl.conf
Listen 443
If I comment out this line in the httpd-ssl.conf file, my apache starts up fine:如果我在 httpd-ssl.conf 文件中注释掉这一行,我的 apache 就可以正常启动:
attempting to start apache
done
However with it I get the socket error every time.但是有了它,我每次都会收到套接字错误。
I ran the following as root:我以 root 身份运行以下命令:
netstat -tlpn | grep :443
Returned nothing.什么都没回。
lsof -i tcp:443
Returned nothing.什么都没回。
I've read somewhere that only root can bind to addresses below 1024, but I don't know the validity of that statement.我在某处读到只有 root 可以绑定到 1024 以下的地址,但我不知道该声明的有效性。 Apache is not being run here as root - would that be the issue?
Apache 没有在此处以 root 身份运行 - 这会是问题吗?
The problem is that 443 is a privileged port, and you are trying to listen as a non-root user.问题是 443 是一个特权端口,而您正试图以非 root 用户身份进行侦听。
See: privileged ports and why are privileged ports restricted to root .请参阅: 特权端口以及为什么特权端口仅限于 root 。
There are also ways to get non-root users to bind to privileged ports . 还有一些方法可以让非 root 用户绑定到特权端口。
If you are using docker with docker-compose,如果您将 docker 与 docker-compose 一起使用,
It happens when we use a non-root container like bitnami official images.当我们使用像bitnami官方镜像这样的非根容器时会发生这种情况。
We used user:root and network_mode: host when it needs to get bind with host network .当需要与主机网络绑定时,我们使用了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
Hope it helps!希望能帮助到你!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.