Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nginx - Protecting PHP files in /storage/ from being executed? #3502

Open
noeminihoul opened this issue Feb 15, 2024 · 1 comment
Open

Nginx - Protecting PHP files in /storage/ from being executed? #3502

noeminihoul opened this issue Feb 15, 2024 · 1 comment

Comments

@noeminihoul
Copy link

Is your feature request related to a problem? Please describe.
When using NGINX, the default.conf is loaded by default. However, it does not protect the storage folder and its subfolders from the execution of PHP files.

Shouldn't this directive be added to prevent attacks?

location ~ ^/storage/.*.php$ {
     add_header Content-Type text/plain;
}
@ccec1t91077
Copy link

ccec1t91077 commented Feb 21, 2024

@noeminihoul If your application does not allow user upload .php then you should filter it in request validation instead filter in web server.

For example, if you used the php artisan view:cache or other cache command, laravel will put the cached file in app/storage/framework/views or app/storage/framework/..., your nginx config will broke it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants