首页 > 解决方案 > Nginx:本地站点加载一段时间,然后以“找不到服务器”中止

问题描述

我刚刚在我的机器上安装了 nginx,并想用一个非常简单的 index.html 对其进行测试。但是,该站点加载了几秒钟,然后以“未找到服务器”中止。这是我的 nginx.conf:

user http;
worker_processes auto;
worker_cpu_affinity auto;

events {
multi_accept on;
worker_connections 1024;
}

http {
charset utf-8;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
log_not_found off;
types_hash_max_size 4096;
client_max_body_size 16M;

# MIME
include mime.types;
default_type application/octet-stream;

# logging
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log warn;

# load configs
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;

server{
    listen 80;
    listen [::]:80;
    server_name test.local;
    root /home/marvw/Programme/Privat/Test;
    location / {
       index index.php index.html index.htm;
    }
  }

 }

比较奇怪的是,错误和访问日志都是空的。我仔细检查了 URL,它绝对是正确的。Nginx 运行没有任何错误,这是我的 systemd 状态输出:

   Active: active (running) since Sat 2019-12-21 00:45:40 +01; 7min ago
  Process: 2171 ExecStart=/usr/bin/nginx -g pid /run/nginx.pid; error_log stderr; (code=exited, status=0/SUCCESS)
 Main PID: 2172 (nginx)
    Tasks: 9 (limit: 4915)
   Memory: 7.9M
   CGroup: /system.slice/nginx.service
           ├─2172 nginx: master process /usr/bin/nginx -g pid /run/nginx.pid; error_log stderr;
           ├─2173 nginx: worker process
           ├─2174 nginx: worker process
           ├─2175 nginx: worker process
           ├─2176 nginx: worker process
           ├─2177 nginx: worker process
           ├─2178 nginx: worker process
           ├─2179 nginx: worker process
           └─2180 nginx: worker process

Dez 21 00:45:40 <<personal information>> systemd[1]: Starting A high performance web server and a reverse proxy server...
Dez 21 00:45:40  <<personal information>> systemd[1]: Started A high performance web server and a reverse proxy server.

标签: nginxserver

解决方案


尝试添加test.local到您的主机或将其更改为localhost. “找不到服务器”不是 Nginx 问题。


推荐阅读