NGINX server_name 不起作用

Hoa*_*Lam 2 nginx

我在 nginx 中遇到了以下有关 server_name 的问题,可能需要您的帮助。这是我default.cnf居住的地方/etc/nginx/conf.d/

server {
    listen       80;
    server_name  planner.dev;

    root   /var/www/planner.dev/src;
    index  index.php index.html index.htm;
    ...
}
Run Code Online (Sandbox Code Playgroud)

我有一个 helloworld html 文件/var/www/planner.dev/src ,但是,只会localhost运行,planner.dev不会运行。

$ curl planner.dev
curl: (6) Couldn't resolve host 'planner.dev'
Run Code Online (Sandbox Code Playgroud)

Acs*_*sor 7

问题很可能出在托管服务器的系统中,而不是服务器本身。

我在 Debian 上运行 Nginx 服务器,碰巧遇到了同样的问题,我通过编辑文件解决了这个问题/etc/hosts

127.0.0.1       localhost
127.0.0.1       vacuum
127.0.0.1       <mywebsite>.localhost
Run Code Online (Sandbox Code Playgroud)

有关主机文件的更多信息。