关于 Linux windows 平台上的Nginx 403错误

来源:互联网 发布:喋血街头java 编辑:程序博客网 时间:2024/05/24 06:29

 我们在启动Nginx的时候往往会遇到403错误,我这里没有存在index.html和index.htm文件所以

 报错:

我的配置文件如下

 1:conf/vhost/www.listore.com.conf 

server {

    listen       80;
   
    server_name  www.listore.com;


    location / {
    root   F:\SVN;
  index  index.html  index.htm;
                                #autoindex on;  
            #autoindex_exact_size on;  
            #autoindex_localtime on;

    }

    }

出现错误的原因是没有找到index.html 和index.htm文件

加上如下配置

autoindex on;  
autoindex_exact_size on;  
autoindex_localtime on;

自动罗列所指定文件夹里面的子目录或者子文件这样就不会报403错误了

主配置文件:

   #user  nobody;
worker_processes  1;


#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;


#pid        logs/nginx.pid;




events {
    worker_connections  1024;
}




http {
    include       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  logs/access.log  main;


    sendfile        on;
    #tcp_nopush     on;


    #keepalive_timeout  0;
    keepalive_timeout  65;


    #gzip  on;


    server {
        listen       80;
        server_name  localhost;


        #charset koi8-r;


        #access_log  logs/host.access.log  main;


        location / {
            root   html;
            index  index.html index.htm;
        }


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


        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}


        # 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  /scripts$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;
        #}
    }


     include   vhost/*.conf;
     
    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;


    #    location / {
    #        root   html;
   #        index  index.html index.htm;
    #    }
    #}




    # HTTPS server
                  #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;


    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;


    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;


    #    ssl_ciphers  HIGH:!aNULL:!MD5;
   #    ssl_prefer_server_ciphers  on;


    #    location / {
   #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
}

阅读全文
0 0
原创粉丝点击