nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

nginx Block Images in wp-uploads

This is a discussion on nginx Block Images in wp-uploads within the Web servers forums, part of the Mastering Servers category; Hi all..I am using nginx for my personal wordpress blog..I wanted to know how to restrict a file type in ...


Go Back   nixCraft Linux Forum > Mastering Servers > Web servers

Linux answers from nixCraft.


Web servers Discussion on Apache, Nginx and Lighttpd HTTP/web server and configuration issues.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 19-11-2009, 01:12 AM
vamsi's Avatar
Senior Member
User
 
Join Date: Nov 2009
Location: Bangalore / India
OS: Ubuntu , Debian Lenny , CentOS 5.x
Posts: 109
Thanks: 70
Thanked 7 Times in 5 Posts
Rep Power: 1
vamsi will become famous soon enough
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
Reply With Quote
  #2 (permalink)  
Old 19-11-2009, 05:34 AM
jaysunn's Avatar
Powered By Linux
User
 
Join Date: Apr 2009
Location: 41.332032,-73.089775
OS: RHEL - OSX
Scripting language: BASH - Learning Ruby
Posts: 602
Thanks: 61
Thanked 80 Times in 72 Posts
Rep Power: 10
jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold
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
__________________
Have a look at what I have been working on
http://www.shellasaurus.com
Reply With Quote
  #3 (permalink)  
Old 19-11-2009, 08:25 AM
vamsi's Avatar
Senior Member
User
 
Join Date: Nov 2009
Location: Bangalore / India
OS: Ubuntu , Debian Lenny , CentOS 5.x
Posts: 109
Thanks: 70
Thanked 7 Times in 5 Posts
Rep Power: 1
vamsi will become famous soon enough
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
Reply With Quote
  #4 (permalink)  
Old 19-11-2009, 11:04 AM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 245 Times in 184 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
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
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help

Last edited by nixcraft; 19-11-2009 at 11:10 AM.
Reply With Quote
The Following User Says Thank You to nixcraft For This Useful Post:
vamsi (19-11-2009)
  #5 (permalink)  
Old 19-11-2009, 11:15 AM
vamsi's Avatar
Senior Member
User
 
Join Date: Nov 2009
Location: Bangalore / India
OS: Ubuntu , Debian Lenny , CentOS 5.x
Posts: 109
Thanks: 70
Thanked 7 Times in 5 Posts
Rep Power: 1
vamsi will become famous soon enough
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
Reply With Quote
  #6 (permalink)  
Old 20-11-2009, 12:44 AM
raj's Avatar
raj raj is offline
Senior Member
User
 
Join Date: Jun 2005
Location: Hyderabad
OS: Fedora, Debian Linux
Posts: 307
Thanks: 42
Thanked 8 Times in 8 Posts
Rep Power: 6
raj will become famous soon enough raj will become famous soon enough
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
Reply With Quote
  #7 (permalink)  
Old 20-11-2009, 09:15 AM
vamsi's Avatar
Senior Member
User
 
Join Date: Nov 2009
Location: Bangalore / India
OS: Ubuntu , Debian Lenny , CentOS 5.x
Posts: 109
Thanks: 70
Thanked 7 Times in 5 Posts
Rep Power: 1
vamsi will become famous soon enough
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
Reply With Quote
  #8 (permalink)  
Old 04-12-2009, 07:03 PM
yog yog is offline
Junior Member
User
 
Join Date: Sep 2009
OS: Centos
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
yog is on a distinguished road
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.
Reply With Quote
Reply

Tags
nginx , nginx location , nginx restirct file types


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Linux Automatically mount NFS and ISO Images on Boot san CentOS / RHEL / Fedora 1 28-12-2008 08:01 PM
How to block ultrasurf mail.mohanasundaram Networking, Firewalls and Security 0 16-08-2008 12:15 PM
Verify Fedora 7 ISO images to get rid of burn error problem deonitin Getting started tutorials 2 26-07-2007 04:41 PM
Secure vsftpd FTP permissions on anonymous user uploads nixcraft Getting started tutorials 6 20-12-2006 02:00 AM
How can I add custom watermarks to images from shell prompt? ac1 Linux software 2 20-12-2005 10:53 PM


All times are GMT +5.5. The time now is 06:53 PM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38