我是一个关于设置生产机器的新人,我不知道为什么我没有在我的EC2机器上看到nginx的默认索引页面。它已在我的服务器上安装并运行,但是当我尝试访问时,它会继续加载并且不显示任何内容,保持在空白页面上。我试图通过公共IP(35.160.22.104)和公共dns(ec2-35-160-22-104.us-west-2.compute.amazonaws.com)访问。两者都是一样的。我做错了什么?
更新: 我意识到重启nginx服务时,它没有显示“ok”消息。所以我看了一下error.log:
[ 2016-12-12 17:16:11.2439 709/7f3eebc93780 age/Cor/CoreMain.cpp:967 ]: Passenger core shutdown finished
2016/12/12 17:16:12 [info] 782#782: Using 32768KiB of shared memory for push module in /etc/nginx/nginx.conf:71
[ 2016-12-12 17:16:12.2742 791/7fb0c37a0780 age/Wat/WatchdogMain.cpp:1291 ]: Starting Passenger watchdog...
[ 2016-12-12 17:16:12.2820 794/7fe4d238b780 age/Cor/CoreMain.cpp:982 ]: Starting Passenger core...
[ 2016-12-12 17:16:12.2820 794/7fe4d238b780 age/Cor/CoreMain.cpp:235 ]: Passenger core running in multi-application mode.
[ 2016-12-12 17:16:12.2832 794/7fe4d238b780 age/Cor/CoreMain.cpp:732 ]: Passenger core online, PID 794
[ 2016-12-12 17:16:12.2911 799/7f06bb50a780 age/Ust/UstRouterMain.cpp:529 ]: Starting Passenger UstRouter...
[ 2016-12-12 17:16:12.2916 799/7f06bb50a780 age/Ust/UstRouterMain.cpp:342 ]: Passenger UstRouter online, PID 799
无论如何,它看起来不像是错误,而是通常的日志。
更新2: Nginx正在运行:
root 810 1 0 17:16 ? 00:00:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 815 810 0 17:16 ? 00:00:00 nginx: worker process
ubuntu 853 32300 0 17:44 pts/0 00:00:00 grep --color=auto nginx
当我尝试curl localhost时,它会按预期返回HTML!
UPDATE3:
当我运行systemctl status nginx
时,我收到以下错误:
Dec 12 17:54:48 ip-172-31-40-156 systemd[1]: nginx.service: Failed to read PID from file /run/nginx.pid: Invalid argument
试图找出它是什么
UPDATE4:
执行命令nmap 35.160.22.104 -Pn PORT STATE SERVICE 22/tcp
并获得输出:
Starting Nmap 7.01 ( https://nmap.org ) at 2016-12-12 18:05 UTC
Failed to resolve "PORT".
Failed to resolve "STATE".
Failed to resolve "SERVICE".
Unable to split netmask from target expression: "22/tcp"
Nmap scan report for ec2-35-160-22-104.us-west-2.compute.amazonaws.com (35.160.22.104)
Host is up (0.0015s latency).
Not shown: 999 filtered ports
PORT STATE SERVICE
22/tcp open ssh
UPDATE5:
netstat -tuanp | grep 80
的输出:
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
tcp6 0 0 :::80 :::* LISTEN -
答案 0 :(得分:2)
您的ec2实例已关联安全组。 您应该转到AWS控制台EC2 - >实例 - >点击您的实例 - >在底部'描述' - >安全组。点击名称,您将重定向到EC2->网络与安全。点击“编辑入站规则”添加规则:
保存。这应该没事!