在 centos 上的 NGINX 上配置 ssl:错误消息

在 centos 上的 NGINX 上配置 ssl:错误消息

当我将 ssl 添加到我的 nginx.conf 时出现以下错误:[emerg]:“server”指令在 /etc/nginx/nginx.conf:106 中不允许使用

NGINX 版本:nginx/0.8.54

这是我的 nginx.conf 的样子:

#######################################################################
#
# 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;

你能帮忙吗?谢谢!Elad。

答案1

您在哪里添加了新server块?错误消息表示它位于不允许添加的位置;server也许是在现有部分内?

相关内容