2017-10-11 20 views
0

올바르게 작동하는 설정이있는 서버 (nginx/1.6.0 PHP 5.5.14)가 있습니다. location ^~ /sys/ sys 폴더에 액세스하려고하면 색인이 다운로드됩니다. location ^~/sys /을 정상적으로 작동하도록 제거하면. 그는 PHP 파일에서만 오류가 발생합니다. html 파일은 정상적으로 작동합니다. 오류는 어디에 있습니까?Nginx 파일을 다운로드 중

server { 
    server_name site.com; 
    root /home/www/site.com; 
    index index.php index.html index.htm; 

    location/{ 
     index index.php index.html; 
     try_files $uri $uri/ /index.php; 
    } 

    location ~ [^/]\.php(/|$) { 
     fastcgi_pass unix:/data/php5514/var/run/php5-fpm.sock; 
     fastcgi_index index.php; 
     fastcgi_read_timeout 300; 
     include fastcgi_params; 
    } 

    location ^~ /sys/ { 
    } 
} 

나는 스크립트를 사용하고 있으며 무단 액세스로부터 폴더를 보호하기 위해이 설정을 nginx에서 수행해야합니다.

location ^~ /FOLDER/ { 
    if ($cookie_amember_nr !~* [a-zA-Z0-9]+) { #not authorized 
     rewrite ^(.*)$ http://EXAMPLE.COM/AMEMBER/protect/new-rewrite?f=FOLDERID&url=$request_uri?$args redirect; 
    } 
    set $file $document_root/AMEMBER/data/new-rewrite/$cookie_amember_nr-FOLDERID; 
    if (!-f $file) { #have not access 
     rewrite ^(.*)$ http://EXAMPLE.COM/AMEMBER/no-access/folder/id/FOLDERID?url=$request_uri?$args redirect; 
    }  
    #everything is ok 
} 

그러나 location^~의 경우이 문제는 해결되지 않습니다.

+0

전문적인 서버 또는 네트워킹 관련 인프라 관리 **에 대한 질문은 프로그래밍 또는 프로그래밍 도구와 직접 관련되지 않는 한 스택 오버플로에 대해 논쟁의 여지가 없습니다. [Server Fault] (http://serverfault.com/about)에서 도움을받을 수 있습니다. – icecub

답변

0

실제 예상되는 내용을 더 자세히 설명해야합니다. 당신은 /에서 sys /에서 PHP는 콘텐츠를 제공 할 가정

, 당신은 또한과 같이이 위치 컨텍스트에서 fastcgi_pass 블록을 넣어해야합니다

location ^~ /sys/ { 
    fastcgi_pass unix:/data/php5514/var/run/php5-fpm.sock; 
    fastcgi_index index.php; 
    fastcgi_read_timeout 300; 
    include fastcgi_params; 
} 

을 만약 당신이 원하는 경우, 당신은 propably 사용할 것 upstream :

upstream php { server unix:/data/php5514/var/run/php5-fpm.sock; } 

및 O

location ^~ /sys/ { 
    fastcgi_pass http://php; 
} 

로 참조 n both/모든 위치 블록이 PHP를 제공합니다.

정확히 일치하는 위치는 덜 정확하거나 거의 일치하는 것을 기억하십시오. 어쩌면 /sys/something.php에 대한 GET 요청은 php-location 블록과 일치하지 않지만/sys-location 블록에 의해 일치 될 수 있습니다. 어쨌든 sys-location 블록의 용도는 다른 루트와 같은 것을 넣지 않으면 무엇입니까?

+0

/sys/폴더에서 예상 한 것은 파일 및 하위 폴더에 액세스하려고 할 때 파일 다운로드와 함께 반환되지 않는다는 것입니다. –

+0

어떤 파일이 있습니까? PHP? – roothahn