nixCraft Linux / UNIX / Shell Scripting 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 ...


Register free or login to your account to remove all advertisements.

Go Back   nixCraft Linux / UNIX / Shell Scripting Forum > Mastering Servers > Web servers

Linux answers from nixCraft.


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

Reply

 

Thread Tools Display Modes
  #1 (permalink)  
Old 19th November 2009, 01:12 AM
vamsi's Avatar
Senior Member
 
Join Date: Nov 2009
Location: Bangalore / India
OS: Ubuntu, CentOS
Scripting language: php
Posts: 189
Thanks: 114
Thanked 9 Times in 7 Posts
Rep Power: 2
vamsi will become famous soon enoughvamsi 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 19th November 2009, 05:34 AM
jaysunn's Avatar
Contributors
 
Join Date: Apr 2009
Location: 41.332032,-73.089775
OS: Red Hat Linux
Scripting language: bash awk sed
Posts: 793
Thanks: 116
Thanked 107 Times in 97 Posts
Rep Power: 14
jaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud of
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 19th November 2009, 08:25 AM
vamsi's Avatar
Senior Member
 
Join Date: Nov 2009
Location: Bangalore / India
OS: Ubuntu, CentOS
Scripting language: php
Posts: 189
Thanks: 114
Thanked 9 Times in 7 Posts
Rep Power: 2
vamsi will become famous soon enoughvamsi 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 19th November 2009, 11:04 AM
nixcraft's Avatar
Never say die
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash, Perl, Python
Posts: 3,294
Thanks: 13
Thanked 411 Times in 304 Posts
Rep Power: 10
nixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft has a reputation beyond reputenixcraft 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
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Do you run a Linux? Let's face it, you need help!
Cricket & IPL News Blog

Last edited by nixcraft; 19th November 2009 at 11:10 AM.
Reply With Quote
The Following User Says Thank You to nixcraft For This Useful Post:
vamsi (19th November 2009)
  #5 (permalink)  
Old 19th November 2009, 11:15 AM
vamsi's Avatar
Senior Member
 
Join Date: Nov 2009
Location: Bangalore / India
OS: Ubuntu, CentOS
Scripting language: php
Posts: 189
Thanks: 114
Thanked 9 Times in 7 Posts
Rep Power: 2
vamsi will become famous soon enoughvamsi 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 20th November 2009, 12:44 AM
raj's Avatar
raj raj is offline
Senior Member
 
Join Date: Jun 2005
Location: Hyderabad
OS: Fedora, Debian Linux
Posts: 342
Thanks: 48
Thanked 10 Times in 10 Posts
Rep Power: 7
raj will become famous soon enoughraj 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 20th November 2009, 09:15 AM
vamsi's Avatar
Senior Member
 
Join Date: Nov 2009
Location: Bangalore / India
OS: Ubuntu, CentOS
Scripting language: php
Posts: 189
Thanks: 114
Thanked 9 Times in 7 Posts
Rep Power: 2
vamsi will become famous soon enoughvamsi 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 4th December 2009, 07:03 PM
yog yog is offline
Junior Member
 
Join Date: Sep 2009
OS: Centos
Posts: 4
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 28th December 2008 08:01 PM
How to block ultrasurf mail.mohanasundaram Networking, Firewalls and Security 0 16th August 2008 12:15 PM
Verify Fedora 7 ISO images to get rid of burn error problem deonitin Getting started tutorials 2 26th July 2007 04:41 PM
Secure vsftpd FTP permissions on anonymous user uploads nixcraft Getting started tutorials 6 20th December 2006 02:00 AM
How can I add custom watermarks to images from shell prompt? ac1 Linux software 2 20th December 2005 10:53 PM


All times are GMT +5.5. The time now is 08:57 AM.


Powered by vBulletin® Version 3.8.6 - 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 39 40