【问题标题】:Nginx server block ERR_NAME_NOT_RESOLVEDNginx 服务器块 ERR_NAME_NOT_RESOLVED
【发布时间】:2017-03-08 01:11:56
【问题描述】:

我在 Ubuntu 14.04.5 服务器上运行 Nginx。我正在尝试设置一个新的服务器块,但是当我导航到 URL 时,我看到了这个错误:

我对此虚拟主机的配置如下。

我希望我的子域指向的目录是/var/www/vhosts/ny-video.splashpreviews.com

/etc/nginx/sites-available 中是我的服务器块文件。该文件的服务器配置部分如下:

server {
listen *:80;
listen [::]:80;

root /var/www/vhosts/ny-video.splashpreviews.com;
index index.php index.html index.htm;

# Make site accessible from http://localhost/
server_name ny-video.splashpreviews.com;
}

然后我启用了服务器块并重新启动了 Nginx。在此过程中是否有我遗漏的东西或我做错了什么导致它不起作用?任何指导将不胜感激。谢谢。

【问题讨论】:

  • 您是否为主机名添加了 DNS 条目?好像没有。
  • 谢谢。我添加了 DNS 条目,现在它显示“Web 服务器的默认页面”,所以它仍然无法正常工作。我的设置中缺少什么?

标签: nginx server


【解决方案1】:

您需要将splashpreviews.com 站点添加到配置并允许服务器的位置。可以有多个location 部分,限制对每个子目录的访问。

http {
  limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
  include     /etc/nginx/mime.types;
  ....
  server {
    listen 80;
    server_name splashpreviews.com www.splashpreviews.com;
    location / {
      allow all;
    }
    ....
  }
  server {
    listen 80;
    server_name ny-video.sp.com;
    location / {
      allow all;
    }

【讨论】:

  • 我尝试将此添加到我的配置中,但我的域仍显示“Web 服务器的默认页面”ny-video.splashpreviews.com。我的设置中是否遗漏了一些重要的东西?
  • 是的。将 ny-viedo ... 添加到 server_name 中的域列表
  • 现在我看到这条消息:欢迎使用 nginx!如果您看到此页面,则 nginx Web 服务器已成功安装并正在运行。需要进一步配置。有关在线文档和支持,请参阅 nginx.org。 nginx.com 上提供了商业支持。感谢您使用 nginx。
  • 恭喜!现在将 document_root 或代理设置为 apache - 只需 1-2 步即可
猜你喜欢
  • 1970-01-01
  • 2018-06-18
  • 2021-01-25
  • 1970-01-01
  • 1970-01-01
  • 2019-03-22
  • 2017-04-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多