C4f1151075b447779af31e99d6cf70e2c6eb47ac
By:
newbie

trying to secure my application & wordpress upload folder but no luck :(

October 17, 2016 510 views
Nginx PHP WordPress Ubuntu

hi,
i was trying to secure my wordpress site and applications upload folder with the following command but its not working. i can still upload those denied file types. can somebody tell me what im doing wrong here?

location ~* ^/upload/directory/.*.(html|htm|shtml|php|js|swf)$ {
deny all;
}

1 Answer

The deny all option tells the web server what types of files it should not serve in this case. This setting should prevent files of those types from being displayed but not from being uploaded. If you want to restrict file upload types this would need to be done in the application processing the uploads, in this case, WordPress. You may want to investigate plugins that will give you the ability to restrict uploads in this way.

  • @ryanpq
    ok. i understand your point.
    i found that from nginx own blog though.
    https://www.nginx.com/blog/9-tips-for-improving-wordpress-performance-with-nginx/
    Check Tip 8

    and after writing in their blog, one of their mod asked me to escape the second dot with a back slash.

    location ~* ^\/upload\/directory\/.*\.(html|htm|shtml|php|js|swf)$ {
        deny all;
    }
    

    but unfortunately i didnt tried with above pattern in my existing project. but will give a try on my next project as it looks important feature to me.

    thanks for your response anyway.

Have another answer? Share your knowledge.