zoukankan      html  css  js  c++  java
  • nginx+php 访问静态文件例如js、css等出现403 Access denied. 问题笔记

    在新搭建的web服务中访问静态文件出现了403,  响应Access denied. 问题截图:

    下面是nginx 的配置:

     1 server
     2 {
     3        listen       8010;
     4        server_name xxx.xxx.xxx;
     5        index index.html index.htm index.php;
     6        root  /xxx/xxxx/xxxx;
     7 
     8        location ~ .*.(php|php5)?
     9        {
    10            fastcgi_pass  unix:/dev/shm/php-cgi.sock;
    11            fastcgi_index index.php;
    12            include fastcgi.conf;      
    13        }
    14        
    15        location ~ .*.(gif|jpg|jpeg|png|bmp|swf|data|js|css|html|htm|ico)$  
    16        {
    17              expires      1d;
    18        }   
    19       
    20        
    21        
    22 
    23        access_log /xxx/xxx/nginx_logs/xxx_access.log main;
    24 }

     在网上找了些方法:

    1、修改php-fpm.conf中的security.limit_extensions

    2、修改php.ini     cgi.fix_pathinfo = 0 改为 "1"

    最后发现设置了security.limit_extensions 但是根本不解析js和css文件,导致页面样式混乱。

    感觉还是nginx配置的问题,应该是所有的请求全部都走了php导致的,仔细查看nginx配置发现是这一行:location ~ .*.(php|php5)?     少了$,

    ? 是0次或1次,所以在0次的时候并且没有以php结尾的请求也进了php,导致没有走下边的逻辑。

    所以还是粗心导致的bug,记录在此,如有遇到同样问题的同学可以少走些弯路。

  • 相关阅读:
    HDU 3835 R(N)
    HDU 2498 Digits
    HUST 1027 Enemy Target!
    【POJ 3714】 Raid
    【POJ 2965】 The Pilots Brothers' refrigerator
    【POJ 2054】 Color a Tree
    【POJ 1328】 Radar Installation
    【POJ 3190】 Stall Reservations
    【POJ 3614】 Sunscreen
    【BZOJ 3032】 七夕祭
  • 原文地址:https://www.cnblogs.com/liyante/p/13217876.html
Copyright © 2011-2022 走看看