我最近使用标准安装选项将我的服务器操作系统从 CentOS 7 迁移到 CentOS 8 流。现在我在访问 HTTP/S 服务器时遇到错误。
假设您在端口 80 或 443 上运行 http 服务器。例如使用 python 模块http.server
:
$> sudo python3 -m http.server -b xxx.xxx.xxx.xxx 80[or 443]
这里,xxx.xxx.xxx.xxx 代表公网 IP,http.server
可以替换为任何 Web 服务器,如 Apache、Nginx 或 Podman 容器。
为了避免防火墙的影响,我禁用了firewalld.service
:
$> sudo systemctl stop firewalld.service
此外,在运行 http 服务器之前,我已经通过以下方式确认没有其他进程在侦听端口 80 或 443:
$> netstat -lnt | grep 80[or 443]
$> # nothing returned
因此,通常当有人访问此服务器时,例如使用:
curl xxx.xxx.xxx.xxx
它应该以来自正在运行的服务器的一些内容来响应,例如当前目录下的文件夹和文件。
但就我而言,此命令在端口 80 上返回“404 页面未找到”和“客户端向 HTTPS 服务器发送了 HTTP 请求”。分别在纯文本的端口 443 上。此错误仅发生在具有公共 IP 访问权限的端口 80 和 443 上,这意味着以下操作有效。
$> curl localhost
其实,有没有运行的http服务器并不重要。似乎有一个不可见的 HTTP 服务器并以更高的优先级运行。
我尝试了很多来处理这个错误,发现当状态firewalld.service
改变时,例如停止/启动/重新启动firewalld.service
,改变后会有很短的时间(大约10秒)可以正常访问正在运行的服务器。
所有正在运行的服务都列出如下:
liuchang@xenonpy ~ ❯❯❯ systemctl --type=service --state=running
UNIT LOAD ACTIVE SUB DESCRIPTION
accounts-daemon.service loaded active running Accounts Service
atd.service loaded active running Job spooling tools
auditd.service loaded active running Security Auditing Service
avahi-daemon.service loaded active running Avahi mDNS/DNS-SD Stack
chronyd.service loaded active running NTP client/server
colord.service loaded active running Manage, Install and Generate Color Profiles
crond.service loaded active running Command Scheduler
cups.service loaded active running CUPS Scheduler
dbus.service loaded active running D-Bus System Message Bus
firewalld.service loaded active running firewalld - dynamic firewall daemon
gdm.service loaded active running GNOME Display Manager
gssproxy.service loaded active running GSSAPI Proxy Daemon
irqbalance.service loaded active running irqbalance daemon
k3s.service loaded active running Lightweight Kubernetes
ksmtuned.service loaded active running Kernel Samepage Merging (KSM) Tuning Daemon
libstoragemgmt.service loaded active running libstoragemgmt plug-in server daemon
mcelog.service loaded active running Machine Check Exception Logging Daemon
ModemManager.service loaded active running Modem Manager
NetworkManager.service loaded active running Network Manager
packagekit.service loaded active running PackageKit Daemon
polkit.service loaded active running Authorization Manager
rdma-ndd.service loaded active running RDMA Node Description Daemon
rhsmcertd.service loaded active running Enable periodic update of entitlement certificates.
rngd.service loaded active running Hardware RNG Entropy Gatherer Daemon
rpcbind.service loaded active running RPC Bind
rsyslog.service loaded active running System Logging Service
rtkit-daemon.service loaded active running RealtimeKit Scheduling Policy Service
smartd.service loaded active running Self Monitoring and Reporting Technology (SMART) Daemon
sshd.service loaded active running OpenSSH server daemon
sssd.service loaded active running System Security Services Daemon
systemd-journald.service loaded active running Journal Service
systemd-logind.service loaded active running Login Service
systemd-machined.service loaded active running Virtual Machine and Container Registration Service
systemd-udevd.service loaded active running udev Kernel Device Manager
tuned.service loaded active running Dynamic System Tuning Daemon
udisks2.service loaded active running Disk Manager
upower.service loaded active running Daemon for power management
user@1000.service loaded active running User Manager for UID 1000
user@42.service loaded active running User Manager for UID 42
wpa_supplicant.service loaded active running WPA supplicant
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
40 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
我对此一无所知,希望有人可以帮助我。提前致谢!