为什么我无法访问此站点的此页面,但我的终端上似乎没有错误?
当我通过IP 地址访问服务器时,它很好:
但是有了域名,我得到了这个:
$ sudo systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2017-04-06 04:19:23 BST; 7h ago
Process: 7248 ExecStart=/usr/bin/nginx -g pid /run/nginx.pid; error_log stderr; (code=exited, status=0/SUCCESS)
Main PID: 7250 (nginx)
Tasks: 2 (limit: 512)
CGroup: /system.slice/nginx.service
├─7250 nginx: master process /usr/bin/nginx -g pid /run/nginx.pid; error_log stderr
└─7251 nginx: worker process
Apr 06 04:19:23 localhost systemd[1]: Starting A high performance web server and a reverse proxy server...
Apr 06 04:19:23 localhost systemd[1]: Started A high performance web server and a reverse proxy server.
Apr 06 04:20:00 localhost nginx[7248]: 2017/04/06 04:20:00 [error] 7251#7251: *6 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 183.171
Apr 06 07:14:44 localhost nginx[7248]: 2017/04/06 07:14:44 [error] 7251#7251: *506 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 195.2
Apr 06 08:27:06 localhost nginx[7248]: 2017/04/06 08:27:06 [error] 7251#7251: *574 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 138.2
Apr 06 11:04:58 localhost nginx[7248]: 2017/04/06 11:04:58 [error] 7251#7251: *835 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 183.1
Apr 06 11:17:27 localhost nginx[7248]: 2017/04/06 11:17:27 [error] 7251#7251: *841 open() "/usr/share/nginx/html/robots.txt" failed (2: No such file or directory), client: 66.249
Apr 06 11:31:40 localhost nginx[7248]: 2017/04/06 11:31:40 [error] 7251#7251: *845 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 183.1
Apr 06 11:32:56 localhost
这似乎是错误:
*6 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 183.171
这是什么意思?与域名无关!
这是我的配置的一部分:
server {
listen 80;
server_name example.co.uk www.example.co.uk;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
}
server {
listen 443 ssl;
server_name example.co.uk www.example.co.uk;
ssl_certificate /etc/letsencrypt/live/example.co.uk/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.co.uk/privkey.pem;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location ~ /.well-known {
allow all;
}
}
server {
listen 8888 ssl;
server_name example.co.uk www.example.co.uk;
ssl_certificate /etc/letsencrypt/live/example.co.uk/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.co.uk/privkey.pem;
location ~ /.well-known {
allow all;
}
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:3838;
}
}
测试代码:
$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
以前一切正常,但现在突然停止了。
有任何想法吗?
我按照本指南在我的 Arch Linux 上安装 Nginx。
我采取的步骤:
$ sudo pacman -Syu
$ sudo pacman -S nginx
启动 Nginx 服务并使用以下命令使其在启动时启动:
$ sudo systemctl start nginx
$ sudo systemctl enable nginx
编辑:
我现在已经卸载了 Ngnix 并重新安装了它,但是即使在没有任何/etc/nginx/nginx.conf
. 我得到的是在浏览器上无法访问此站点。
为什么!??
我检查了一下netstat
,我可以看到端口 80 在列表中:
$ sudo netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 5361/mongod
tcp 0 0 0.0.0.0:5355 0.0.0.0:* LISTEN 3666/systemd-resolv
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 10701/nginx: master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3667/sshd
tcp 0 0 0.0.0.0:3838 0.0.0.0:* LISTEN 32434/shiny-server
tcp6 0 0 :::5355 :::* LISTEN 3666/systemd-resolv
tcp6 0 0 :::3030 :::* LISTEN 17325/node /usr/loc
tcp6 0 0 :::22 :::* LISTEN 3667/sshd
tcp6 0 0 :::3000 :::* LISTEN 17325/node /usr/loc
udp 0 0 0.0.0.0:5355 0.0.0.0:* 3666/systemd-resolv
udp6 0 0 :::5355 :::* 3666/systemd-resolv
编辑2:
我创建了一个访问日志。但我没有看到任何重大错误:
$ more -f /etc/nginx/logs/access.log
183.171.92.177 - - [06/Apr/2017:12:38:09 +0100] "GET / HTTP/1.1" 200 612 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/57.0.2987.98 Chrome/57.0.2987.98 Safari/537.36" "-"
183.171.92.177 - - [06/Apr/2017:12:38:09 +0100] "GET /favicon.ico HTTP/1.1" 404 571 "http://xxx.xxx.xxx.xx/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/57.0.2987.98 Chrome/57.0.2987.98 Safari/537.36" "-"