我试图在Linux上启用端口443,因为我试图安装SSL证书。我运行了sudo lsof -i -P -n | grep LISTEN,得到了以下内容:
rpcbind 1751 rpc 8u IPv4 15914 0t0 TCP *:111 (LISTEN)
rpcbind 1751 rpc 11u IPv6 15917 0t0 TCP *:111 (LISTEN)
master 2172 root 13u IPv4 17752 0t0 TCP 127.0.0.1:25 (LISTEN)
nginx 2264 root 6u IPv4 19741 0t0 TCP *:80 (LISTEN)
nginx 2264 root 7u IPv6 19742 0t0 TCP *:80 (LISTEN)
nginx 2265 nginx 6u IPv4 19741 0t0 TCP *:80 (LISTEN)
nginx 2265 nginx 7u IPv6 19742 0t0 TCP *:80 (LISTEN)
nginx 2266 nginx 6u IPv4 19741 0t0 TCP *:80 (LISTEN)
nginx 2266 nginx 7u IPv6 19742 0t0 TCP *:80 (LISTEN)
sshd 7640 root 3u IPv4 1317041 0t0 TCP *:22 (LISTEN)
sshd 7640 root 4u IPv6 1317050 0t0 TCP *:22 (LISTEN)sudo netstat -tulpn | grep :443也没有给出任何结果。
我运行sudo iptables -I INPUT -p tcp -m tcp --dport 443 -j ACCEPT,但这不起作用。在这个命令之后,我没有得到任何结果。
我的服务器运行在AWS EC2上,我的安全组启用了HTTPS,但我仍然存在相同的问题。
我的nginx.conf看起来像这样。我添加了一个启用TLS的服务器的设置,该服务器监听端口443:
server {
listen 80;
listen [::]:80;
server_name _;
location / {
root /home/ec2-user;
try_files $uri $uri/ /index.html;
# add_header 'Access-Control-Allow-Origin' '*';
}
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
# Settings for a TLS enabled server.
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name _;
root /home/ec2-user;
ssl_certificate "/etc/pki/nginx/server.crt";
ssl_certificate_key "/etc/pki/nginx/private/server.key";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers PROFILE=SYSTEM;
ssl_prefer_server_ciphers on;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}发布于 2022-02-24 09:44:23
首先,检查ngnix是否与systemctl status nginx一起运行,如果没有,则配置文件有问题,我猜您的ssl证书丢失了。如果是这样的话,那么试着生成证书,并将您在nginx.conf中提到的路径与该dir的所有者放在一起作为nginx。
https://stackoverflow.com/questions/71248200
复制相似问题