无法启动Nginx:"服务器"这里不允许使用指令

时间:2016-10-06 04:28:09

标签: ruby-on-rails azure nginx passenger

我正在尝试运行乘客+ nginx实例。已经成功安装了Passenger,但是在转到http://lakemagazine.northcentralus.cloudapp.azure.com/时我们收到了超时错误。所以,我看了nginx:

garrett@lakemag:~$ sudo nginx -t
nginx: [emerg] "server" directive is not allowed here in /etc/nginx/nginx.conf:65
nginx: configuration file /etc/nginx/nginx.conf test failed

因此,nginx没有运行,我认为这是我的问题。

这是我的nginx.conf文件:

user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml applic$

    ##
    # Virtual Host Configs
    ##

    #include /etc/nginx/conf.d/*.conf;
    #include /etc/nginx/sites-enabled/*;
server {
    listen 80;
    server name http://lakemagazine.northcentralus.cloudapp.azure.com/;

    root /lakemag/public;

    passenger_enabled on;
    passenger_ruby /home/garrett/.rvm/gems/ruby-2.3.0/wrappers/ruby;
    }

}

第65行是我的服务器{}块开始的地方。我对我的问题感到茫然 - 所有的块似乎都适合我。我错过了什么吗?

*编辑:

garrett@lakemag:~$ sudo nginx -t
[sudo] password for garrett:
nginx: [warn] server name "http://lakemagazine.northcentralus.cloudapp.azure.com/" has suspicious symbols in /etc/nginx/nginx.conf:65
nginx: [emerg] unknown directive "passenger_enabled" in /etc/nginx/nginx.conf:69
nginx: configuration file /etc/nginx/nginx.conf test failed

在Jorge的解决方案之后,我现在收到了上述错误。

1 个答案:

答案 0 :(得分:0)

在哪里说:

server name http://lakemagazine.northcentralus.cloudapp.azure.com/

应该说:

server_name http://lakemagazine.northcentralus.cloudapp.azure.com/

server是一个指令,用于定义服务器块并确定您应该在其中编写server_name指令的服务器

http://nginx.org/en/docs/http/server_names.html

要检查配置文件语法,请使用:

nginx -t