Welcome! Log In Create A New Profile

Advanced

apache .htaccess conversion

Posted by saifulmr 
apache .htaccess conversion
October 14, 2011 07:01AM
Hello,
I have recently migrated from Apache 2.2 to nginx 1.08 stable on a Ubuntu 10.10 x64 machine. My /etc/nginx/sites-available/default is like this :-

server {

listen 80; ## listen for ipv4
server_name www.mydomain.com;
access_log /var/log/nginx/localhost.access.log;

location / {
root /var/www/html;
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?q=$request_uri;
}
I have a download section at /var/www/html/downloads (or /downloads) and I have a autoindex PHP script to show all the files within the directory. Now normally there are some .mp3 and .mp4 files inside different folders and sub-folders under /downloads. Some of the directory was also symbolic links like /downloads/videos is symbolic to /media/hdd/videos. I want everyone to access all those folders and see the contents using the autoindex php script (which worked previously fine with apache) ..but cannot download them unless they are from 172.16.0.0/16. Previously I had two .htaccess files to do this. One is in / (root folder) which controls the .htaccess rules for the joomla site, another one in /downloads. The rules inside it are as follows:

ErrorDocument 403 /errors/downloads/403.php

<Files ~ "\.(mp3|mp4)$">
order deny,allow
allow from 172.16.0.0/16
deny from all
</Files>

I am trying to achieve the same with nginx. Can anyone point me to the right direction please?

Regards,
Saiful
Re: apache .htaccess conversion
October 16, 2011 06:02PM
Hello,

Since you asked so nicely:

http://wiki.nginx.org/HttpAccessModule
http://wiki.nginx.org/HttpCoreModule#error_page

:-)

Andrejs
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 190
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready