Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm getting the following error when I add ssl to my nginx.conf: [emerg]: "server" directive is not allowed here in /etc/nginx/nginx.conf:106

NGINX version: nginx/0.8.54

This is hpw my nginx.conf looks like:

#######################################################################
#
# This is the main Nginx configuration file.  
#
# More information about the configuration options is available on 
#   * the English wiki - http://wiki.nginx.org/Main
#   * the Russian documentation - http://sysoev.ru/nginx/
#
#######################################################################

#----------------------------------------------------------------------
# Main Module - directives that cover basic functionality
#
#   http://wiki.nginx.org/NginxHttpMainModule
#
#----------------------------------------------------------------------

user              nginx;
worker_processes  1;

#error_log  /var/log/nginx/error.log;
error_log  /var/log/nginx/error.log  debug;
#error_log  /var/log/nginx/error.log  info;

pid        /var/run/nginx.pid;


#----------------------------------------------------------------------
# Events Module 
#
#   http://wiki.nginx.org/NginxHttpEventsModule
#
#----------------------------------------------------------------------

events {
    worker_connections  1024;
}


#----------------------------------------------------------------------
# HTTP Core Module
#
#   http://wiki.nginx.org/NginxHttpCoreModule 
#
#----------------------------------------------------------------------

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

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    gzip                on;
    gzip_http_version   1.1;
    gzip_proxied        any;
    gzip_types          text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/x-shockwave-flash;
    gzip_vary           on;
    gzip_comp_level     6;

    # make sure gzip does not lose large gzipped js or css files
    # see http://blog.leetsoft.com/2007/7/25/nginx-gzip-ssl
    gzip_buffers 16 8k;

    # Disable gzip for certain browsers.
    gzip_disable “MSIE [1-6].(?!.*SV1)”;

    #
    # The default server
    #
    server {
         rewrite_log on;

        listen       80;
        #server_name  _;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

    root /var/www/live/html;
    #index  index.php index.html index.htm;

       location ~ ^/proxy/ {
        #rewrite ^/proxy/(.*)$ http://$1 permanent;
    #   proxy_set_header X-Forwarded-Host $host;
        #   proxy_set_header X-Forwarded-Server $host;
        #   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    #   proxy_buffering off;
       #       proxy_pass http://$1;

        #rewrite ^/proxy/(.*)\?(.*)$ "/moc/dbaseRoutines/memberServices.php\?u=$1" last;
        rewrite ^/proxy/(.*)?(.*)$ /moc/dbaseRoutines/memberServices.php?$1 last;

        break;
       }

       location / {
        #root /var/www/live/html;
        index index.php index.html index.htm;

        try_files  $uri $uri/ /index.php;
       }

        error_page  404   /404.html;

        # redirect server error pages to the static page /50x.html
        #
        #error_page   500 502 503 504  /50x.html;
        #location = /50x.html {
        #    root   /usr/share/nginx/html;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            #root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /var/www/live/html$fastcgi_script_name;
            include        fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

    # Load config files from the /etc/nginx/conf.d directory
    include /etc/nginx/conf.d/*.conf;

}

    server {
        listen  443 default ssl;
        server_name  our-site.com;

        ssl_certificate  /etc/nginx/ssl/our-site.crt;
        ssl_certificate_key  /etc/nginx/ssl/our-site.key;

        ssl_session_timeout  5m;

        ssl_protocols  SSLv2 SSLv3 TLSv1;
        ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
        ssl_prefer_server_ciphers   on;

can you please help? Thanks! Elad.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Where did you add the new server block? That error message is saying that it's somewhere that it's not allowed; within an existing server section perhaps?

share|improve this answer
    
I'm not sure I understand. when you say server block do you mean the lines above? –  edotan Aug 30 '11 at 17:56
    
if so then I put it at the end of the nginx.conf –  edotan Aug 30 '11 at 17:57
    
@Elad Yes - at line 106, as is stated in your error message. What matters is the context - it'd be easiest if you edited your question to include the whole config file (strip out any private information if you need to). –  Shane Madden Aug 30 '11 at 18:00
    
Hi Shane, I did. hope now you can help! Thanks!! –  edotan Aug 30 '11 at 18:16
    
@Elad Move your new server section to within the http section, below the first server (above the include /etc/nginx/conf.d/*.conf; line). And add a } at the end to close it properly. –  Shane Madden Aug 30 '11 at 18:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.