Results 1 to 8 of 8

Thread: nginx Block Images in wp-uploads

  1. #1
    Senior Member vamsi's Avatar
    Join Date
    Nov 2009
    Location
    Bangalore / India
    Posts
    263
    Thanks
    138
    Thanked 14 Times in 12 Posts
    Rep Power
    7

    Unhappy nginx Block Images in wp-uploads

    Hi all..I am using nginx for my personal wordpress blog..I wanted to know how to restrict a file type in it..
    in other words , I just want to allow image files (jpg,png,gif) in wp-uploads folder for security purposes..
    please guide me

    thanks
    vamsi

  2. #2
    Contributors jaysunn's Avatar
    Join Date
    Apr 2009
    Location
    NYC - USA
    Posts
    1,029
    Thanks
    165
    Thanked 154 Times in 133 Posts
    Rep Power
    24

    Default

    This may be of assistance to you. I have used it once before:

    Secure File Upload Check List With PHP - Hungred Dot Com

    Have a look:

    HTH,

    Jaysunn

  3. #3
    Senior Member vamsi's Avatar
    Join Date
    Nov 2009
    Location
    Bangalore / India
    Posts
    263
    Thanks
    138
    Thanked 14 Times in 12 Posts
    Rep Power
    7

    Arrow

    Quote Originally Posted by jaysunn View Post
    This may be of assistance to you. I have used it once before:

    Secure File Upload Check List With PHP - Hungred Dot Com

    Have a look:

    HTH,

    Jaysunn

    Thank you..
    is there any other way ?
    I had used .htaccess to restrict a file type in apache ..but I dont know how to get this in done in nginx

  4. #4
    Never say die nixcraft's Avatar
    Join Date
    Jan 2005
    Location
    BIOS
    Posts
    4,515
    Thanks
    17
    Thanked 815 Times in 511 Posts
    Rep Power
    10

    Default

    Take a look at location directive. It can be used to match given regex and take some action. For example, following be used to block hotlinking:
    Code:
      
    location ~* (\.jpg|\.png|\.gif)$ {
        valid_referers blocked theos.in www.theos.in;
        if ($invalid_referer) ) {
            return 444;
        }
      }
    Only allow images

    Code:
          location /path/to/your/wp-uploads {
            if ($request_uri ~* (^\/|\.jpg|\.png|\.gif)$ ) {
              break;
            }
            return 444;
          }
    NginxHttpCoreModule
    Last edited by nixcraft; 19th November 2009 at 12:10 PM.
    All [Solved] threads are closed by mods / admin to avoid spam issues. See Howto mark a thread as [Solved]


  5. The Following User Says Thank You to nixcraft For This Useful Post:

    vamsi (19th November 2009)

  6. #5
    Senior Member vamsi's Avatar
    Join Date
    Nov 2009
    Location
    Bangalore / India
    Posts
    263
    Thanks
    138
    Thanked 14 Times in 12 Posts
    Rep Power
    7

    Cool

    Quote Originally Posted by nixcraft View Post
    Take a look at location directive. It can be used to match given regex and take some action. For example, following be used to block hotlinking:
    Code:
      
    location ~* (\.jpg|\.png|\.gif)$ {
        valid_referers blocked theos.in www.theos.in;
        if ($invalid_referer) ) {
            return 444;
        }
      }
    Only allow images

    Code:
          location /path/to/your/wp-uploads {
            if ($request_uri ~* (^\/|\.jpg|\.png|\.gif)$ ) {
              break;
            }
            return 444;
          }
    NginxHttpCoreModule
    it works like charm


    thanks

  7. #6
    Senior Member raj's Avatar
    Join Date
    Jun 2005
    Location
    Hyderabad
    Posts
    566
    Thanks
    57
    Thanked 41 Times in 38 Posts
    Rep Power
    14

    Default

    how fast is nginx? some one said lighttpd is very fast, thoughts?

    I think only large size website need nginx or lighttpd server. Most small site are okay with apache. At least most of our customer run apache.
    Raj
    Linux rulz.
    I have never turned back in my life ; I shall not do so today.. haha

  8. #7
    Senior Member vamsi's Avatar
    Join Date
    Nov 2009
    Location
    Bangalore / India
    Posts
    263
    Thanks
    138
    Thanked 14 Times in 12 Posts
    Rep Power
    7

    Default

    Quote Originally Posted by raj View Post
    how fast is nginx? some one said lighttpd is very fast, thoughts?

    I think only large size website need nginx or lighttpd server. Most small site are okay with apache. At least most of our customer run apache.
    My site is on a 128 mb ram vps so I try all the ways to reduce the ram usage and one of the way I adopted is nginx . I was not able to find any noticeable speed changes on my blog.. also many say that nginx is best for serving static content..and I am just experimenting all types of servers just foe fun will try lighty after my test in college

  9. #8
    Junior Member
    Join Date
    Sep 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default lsof command

    Hello Guys,

    I want to know more about lsof command, however I have basic info of that command which is not sufficient to trace out many things. As lsof is great tool.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Linux Automatically mount NFS and ISO Images on Boot
    By san in forum CentOS / RHEL / Fedora
    Replies: 1
    Last Post: 28th December 2008, 09:01 PM
  2. How to block ultrasurf
    By mail.mohanasundaram in forum Networking, Firewalls and Security
    Replies: 0
    Last Post: 16th August 2008, 01:15 PM
  3. Verify Fedora 7 ISO images to get rid of burn error problem
    By deonitin in forum Getting started tutorials
    Replies: 2
    Last Post: 26th July 2007, 05:41 PM
  4. Secure vsftpd FTP permissions on anonymous user uploads
    By nixcraft in forum Getting started tutorials
    Replies: 6
    Last Post: 20th December 2006, 03:00 AM
  5. Replies: 2
    Last Post: 20th December 2005, 11:53 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •