nginx error: "server" directive is not allowed here

Ask all your questions regarding OC 5.x Please read the Support Forum Rules
Forum rules
ownCloud 5.x reached end of life and is officially unsupported. For details see Wiki page.

Please upgrade your ownCloud.
timm
Newbie
Posts: 7
Joined: Mon Aug 06, 2012 11:52 pm

nginx error: "server" directive is not allowed here

Postby timm » Tue Aug 07, 2012 12:03 am

Hello,

I'm trying to get owncloud running with nginx on my raspberry pi, since apache seems a little over-sized. I installed nginx and copied and modified the text from the owncloud page into nginx.conf and installed the server certs as per instructions. However, the server won't start and gives me a rather vague error message
nginx: [emerg] "server" directive is not allowed here in /usr/local/nginx/conf/nginx.conf:100
about its config file. Line 100 is where the owncloud part starts. Can somebody help me out here, please?

Code: Select all

user www-data;
worker_processes 4;
pid /var/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;

        ##
        # 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/x-javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # nginx-naxsi config
        ##
        # Uncomment it if you installed nginx-naxsi
        ##
        #include /etc/nginx/naxsi_core.rules;

        ##
        # nginx-passenger config
        ##
        # Uncomment it if you installed nginx-passenger
        ##
       
        #passenger_root /usr;
        #passenger_ruby /usr/bin/ruby;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}


#mail {
#       # See sample authentication script at:
#       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#       # auth_http localhost/auth.php;
#       # pop3_capabilities "TOP" "USER";
#       # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#       server {
#               listen     localhost:110;
#               protocol   pop3;
#               proxy      on;
#       }
#
#       server {
#               listen     localhost:143;
#               protocol   imap;
#               proxy      on;
#       }
#}

################### Owncloud

# redirect http to https.
server {
  listen 80;
  server_name apahatchi.homeip.net;
  rewrite ^ https://$server_name$request_uri? permanent;  # enforce https
}

# owncloud (ssl/tls)
 server {
  listen 443 ssl;
  ssl_certificate /etc/nginx/certs/server.crt;
  ssl_certificate_key /etc/nginx/certs/server.key;
  server_name apahatchi.homeip.net;
  root /var/www/owncloud;
  index index.php;
  client_max_body_size 1000M; # set maximum upload size

  # deny direct access
  location ~ ^/(data|config|\.ht|db_structure\.xml|README) {
    deny all;
  }

  # default try order
  location / {
    try_files $uri $uri/ @webdav;
  }

  # owncloud WebDAV
  location @webdav {
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    fastcgi_pass 127.0.0.1:9000; # or use php-fpm with: "unix:/var/run/php-fpm/php-fpm.sock;"
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_params HTTPS on;
    include fastcgi_params;
  }

  # enable php
  location ~ \.php$ {
    fastcgi_pass 127.0.0.1:9000; # or use php-fpm with: "unix:/var/run/php-fpm/php-fpm.sock;"
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_params HTTPS on;
    include fastcgi_params;
  }
}


RealRancor
ownCloud master
Posts: 17381
Joined: Sat May 26, 2012 3:00 pm
ownCloud version: 9.0.2
Webserver: nginx
Database: MySQL
OS: Linux
PHP version: 7.0.x

Re: nginx error: "server" directive is not allowed here

Postby RealRancor » Tue Aug 07, 2012 12:45 am

Hi,

as you can read here:

http://wiki.nginx.org/HttpCoreModule#server

the "server" directive has to be in the "http" directive and no outside of it.
*gone*

timm
Newbie
Posts: 7
Joined: Mon Aug 06, 2012 11:52 pm

Re: nginx error: "server" directive is not allowed here

Postby timm » Tue Aug 07, 2012 1:09 am

Thank you, Rancor, that fixed it.

Funnily enough nginx now complains about the lines

Code: Select all

fastcgi_params HTTPS on;
. If I out-comment them, it seems to work.

RealRancor
ownCloud master
Posts: 17381
Joined: Sat May 26, 2012 3:00 pm
ownCloud version: 9.0.2
Webserver: nginx
Database: MySQL
OS: Linux
PHP version: 7.0.x

Re: nginx error: "server" directive is not allowed here

Postby RealRancor » Tue Aug 07, 2012 11:35 am

Ok, then just try to add this:

Code: Select all

fastcgi_param   HTTPS                   $https;


to your /etc/nginx/fastcgi_params
*gone*

timm
Newbie
Posts: 7
Joined: Mon Aug 06, 2012 11:52 pm

Re: nginx error: "server" directive is not allowed here

Postby timm » Tue Aug 07, 2012 11:14 pm

Thanks again. I had

Code: Select all

fastcgi_param  HTTPS              $https if_not_empty;
in there anyway. Not much of a difference, I suppose?

RealRancor
ownCloud master
Posts: 17381
Joined: Sat May 26, 2012 3:00 pm
ownCloud version: 9.0.2
Webserver: nginx
Database: MySQL
OS: Linux
PHP version: 7.0.x

Re: nginx error: "server" directive is not allowed here

Postby RealRancor » Tue Aug 07, 2012 11:41 pm

That depends on your NginX version / packager. I remember that i had such a problem which the debian packages from dotdeb.org, but it was fixed in an update.
*gone*

timm
Newbie
Posts: 7
Joined: Mon Aug 06, 2012 11:52 pm

Re: nginx error: "server" directive is not allowed here

Postby timm » Wed Aug 08, 2012 12:17 am

I compiled it myself, it's the latest version. So no packager but myself to blame :)

RealRancor
ownCloud master
Posts: 17381
Joined: Sat May 26, 2012 3:00 pm
ownCloud version: 9.0.2
Webserver: nginx
Database: MySQL
OS: Linux
PHP version: 7.0.x

Re: nginx error: "server" directive is not allowed here

Postby RealRancor » Wed Aug 08, 2012 10:51 am

Ok, i don't know how to fix this issue. But that's an NginX issue and not really a problem with OwnCloud so just try to ask your question on the NginX forums:

http://nginx.org/en/support.html
*gone*

timm
Newbie
Posts: 7
Joined: Mon Aug 06, 2012 11:52 pm

Re: nginx error: "server" directive is not allowed here

Postby timm » Wed Aug 08, 2012 11:43 am

Thanks, but you got me wrong, it actually works (tm) now :)

RealRancor
ownCloud master
Posts: 17381
Joined: Sat May 26, 2012 3:00 pm
ownCloud version: 9.0.2
Webserver: nginx
Database: MySQL
OS: Linux
PHP version: 7.0.x

Re: nginx error: "server" directive is not allowed here

Postby RealRancor » Wed Aug 08, 2012 12:43 pm

Ah, sorry. :oops: :D
*gone*


  • Similar Topics
    Replies
    Views
    Last post

Return to “ownCloud Community Edition 5.x and older”

Who is online

Users browsing this forum: Bing [Bot] and 3 guests