我刚刚在新的 ubuntu 实例上安装了 nginx。看起来nginx正在运行,以下是进程:
root 2062 0.0 0.1 85868 1340 ? Ss 01:13 0:00 nginx: master process /usr/sbin/nginx
www-data 2063 0.0 0.1 86212 1768 ? S 01:13 0:00 nginx: worker process
www-data 2064 0.0 0.1 86212 1768 ? S 01:13 0:00 nginx: worker process
www-data 2065 0.0 0.1 86212 1768 ? S 01:13 0:00 nginx: worker process
www-data 2066 0.0 0.1 86212 1768 ? S 01:13 0:00 nginx: worker process
ubuntu 2120 0.0 0.0 10460 932 pts/0 S+ 01:34 0:00 grep --color=auto nginx
Run Code Online (Sandbox Code Playgroud)
这里还有 sudo nstat -plnt
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1076/sshd
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2062/nginx
tcp6 0 0 :::22 :::* LISTEN 1076/sshd
tcp6 0 0 :::80 :::* LISTEN 2062/nginx
Run Code Online (Sandbox Code Playgroud)
但是当我访问我的公共 IP 地址(我没有配置任何站点)时,我的浏览器超时并且不显示默认的 nginx 页面。
nginx 日志中没有错误,并且 sudo nginx -t 看起来很好。我按照一些方法安装并启动了它,但一切都表明它应该立即提供默认主页。
这是我的 /etc/nginx/sites-enabled 中的内容
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
server_name localhost;
location / {
try_files $uri $uri/ =404;
}
}
Run Code Online (Sandbox Code Playgroud)
Lit*_*ain 11
当我在 Digital Ocean 上设置新服务器并遵循他们的教程(其中包括启用简单防火墙)后,我遇到了这个问题。但教程没有提到启用 http 和 https 流量,而您必须这样做!
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-with-ufw-on-ubuntu-20-04
sudo ufw allow http
sudo ufw allow https
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16134 次 |
| 最近记录: |