방금 아파치에서 nginx로 바꿨으며 여전히 익숙해 져 있습니다. (저를 포함한) 많은 사람들이이기 때문에 같은 js|css|jpg|<etc>
로 확장이 403
반응을 얻고있다와 파일 문제를 가지고, Unforunately https://gist.github.com/DarrylDias/be8955970f4b37fdd682Nginx 설정이 작동하지 않습니다.
server {
listen 80;
listen [::]:80;
# SSL configuration
listen 443 ssl;
listen [::]:443 ssl;
ssl on;
ssl_certificate /etc/ssl/private/mydomain.com.crt;
ssl_certificate_key /etc/ssl/private/mydomain.com.private.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_client_certificate /etc/ssl/private/cloudflare.origin-pull-ca.pem;
ssl_verify_client on;
server_name mydomain.com www.mydomain.com;
root /home/vhosts/domains/mydomain.com/public/;
index index.php;
# Leverage browser caching of media files for 30 days
location ~* \.(?:ico|css|js|gif|jpe?g|png|ttf|woff)\$ {
access_log off;
expires 30d;
add_header Pragma public;
add_header Cache-Control "public, mustrevalidate, proxy-revalidate";
}
location/{
try_files $uri $uri/ /index.php?$args;
}
# Deny access to sensitive folders
location ~* /(app|packages|storage|tmp)/.*$ {
return 403;
}
# Deny access to files with the following extensions
location ~* \.(db|json|lock|dist|md)$ {
return 403;
}
# Deny access to following files
location ~ /(config.php|pagekit|composer.lock|composer.json|LICENSE|\.htaccess) {
return 403;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php7-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_param HTTP_MOD_REWRITE On;
}
}
:
나는이 구성을 가진 Pagekit 웹 사이트를 실행 해요 app or packages
디렉토리 안에 있습니다.
여러 정규식을 사용하여이 파일에 대해 location
에 우선 순위를 부여하려고 시도했지만 효과가없는 것으로 보입니다.
이러한 파일을 허용하기 위해이 구성 파일을 변경해야하지만 해당 디렉토리 내의 다른 모든 파일에도 403을 반환해야합니까?
EDIT : 파일 URL이 https://example.com/app/js/something.min.js?v=1921
인 것처럼 보입니다. 아마도 ?v=1921
때문에 작동하지 않습니까? nginx's document에 따르면
검색어가 '위치'블록과 일치하지 않습니다. 당신의 nginx 서버 뒤에 어떤 종류의 CDN이 있습니까? 해당 CDN 서버의 캐시로 인해 발생할 수 있습니다. 캐시를 무시하려면 URL을 https://example.com/app/js/something.min.js?v=1922로 변경하십시오. –
나는 cloudflare를 사용하고 있지만 개발 모드에 있으며 캐시를 지우도록했습니다. 사실은 페이지 킷 자체 때문에 URL이 비슷하다는 것을 알고 있습니다. – xorinzor
캐시는 Cloudflare에 의해 서버 측에 저장되므로 브라우저 개발 모드 만 실제로 작동하지 않습니다. 아마도 "1921"에서 다른 문자열로 버전 번호를 변경하고 마지막 '위치'를 맨 위로 이동 한 후에 작동하는지 확인할 수 있습니다. –