2017-03-08 555 views
0

我在Ubuntu 14.04.5服务器上运行Nginx。我试图建立一个新的服务器块,但是当我浏览到的URL我看到这个错误:Nginx服务器块ERR_NAME_NOT_RESOLVED

Nginx server block error

我给这家虚拟主机配置如下。

,我想我的子域名指向的目录是/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的。有什么我在过程中失踪或我做错了,导致这不起作用?任何指导将不胜感激。谢谢。

+1

您是否为主机名添加了DNS条目?看来你没有。 –

+0

谢谢。我添加了DNS条目,现在它显示“Web服务器的默认页面”,所以它仍然不起作用。我在设置中缺少什么? – Liz

回答

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; 
    } 
+0

我试着将此添加到我的配置中,但我的域仍显示“Web服务器的默认页面”http://ny-video.splashpreviews.com/。我在设置中丢失了一些重要的东西吗? – Liz

+0

是的。将ny-viedo ...添加到server_name中的域列表中 – ETech

+0

现在我看到以下消息:欢迎使用nginx!如果您看到此页面,则说明nginx Web服务器已成功安装并正常工作。需要进一步的配置。有关在线文档和支持,请参阅nginx.org。商业支持可在nginx.com上找到。 感谢您使用nginx。 – Liz