2014-07-04 4 views
0

대신 리디렉션을해야 할 때 nginx에서 404 오류가 발생합니다. 아파치에서 온 것이고 Nginx에서 처음 플레이합니다. 내가 간과하는 사소한 실수가 있어야한다고 생각합니다. 예를 들어Nginx 서버가 제대로 리디렉션되지 않습니다.

server { 
    listen 80 default_server; 
    server_name localhost; 
    root /var/www/resizing/public_html; 
    index index.php index.html index.htm; 

    location ~ ^/(.*)/cache/(.*)$ 
    { 
      try_files $uri @resize; 
      expires 4h; 
    } 

    location/{ 
      expires 4h; 
    } 

    location ~ \.php(.*)$ { 
      #fastcgi_pass 127.0.0.1:8000; 
      fastcgi_pass unix:/var/run/php5-fpm.sock; 
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
      fastcgi_index index.php; 
      include fastcgi_params; 
    } 

    location @resize { 
      rewrite ^/(.*)/cache/(.*)$ /resize.php?dir=$1&path=$2; 
      include fastcgi_params; 
      fastcgi_pass unix:/var/run/php5-fpm.sock; 
    } 



location /doc/ { 
    alias /usr/share/doc/; 
    autoindex on; 
    allow 127.0.0.1; 
    allow ::1; 
    deny all; 
} 

# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests 
#location /RequestDenied { 
# proxy_pass http://127.0.0.1:8080;  
#} 

#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$ { 
# fastcgi_split_path_info ^(.+\.php)(/.+)$; 
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini 
# 
# # With php5-cgi alone: 
# fastcgi_pass 127.0.0.1:9000; 
# # With php5-fpm: 
# try_files $uri =404; 
# fastcgi_pass unix:/var/run/php5-fpm.sock; 
# fastcgi_index index.php; 
# fastcgi_param SCRIPT_FILENAME $document_root$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; 
#} 

}

내가 입력하는 경우 :

코드입니다 로컬 호스트/캐시/150x200-0/원본/1.JPG 나는 404error를 얻을.

답변

1

URI가 /cache/150x200-0/originals/1.jpg이고 구성에 location ~ ^/(.*)/cache/(.*)$과 일치하지 않는 것이 문제입니다.

올바른 위치 (이하 "DIR"구성 요소가 실제로 필요한 가정)과 같이 표시됩니다

location ~ ^(/.*)?/cache/(.*)$ { 
    ... 
} 

참고도 같은 문제가 location @resize에 사용되는 rewrite에 있는지.

+0

그 덕분에 Maxim을 사용할 수있었습니다. 고마워요! – ablazq

관련 문제