# Nginx and Zencart

**URL:** <https://www.ruby-forum.com/t/nginx-and-zencart/222778>\
**Category:** NGINX\
**Created:** [September 10, 2012, 2:17pm UTC](https://www.ruby-forum.com/t/nginx-and-zencart/222778 "2012-09-10T14:17:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [September 10, 2012, 2:17pm UTC](https://www.ruby-forum.com/t/nginx-and-zencart/222778/1 "2012-09-10T14:17:11Z")

</div>

I am wanting to utilize nginx with zencart. The issue I am having  
isn’t getting Zencart to work, but to recreate the .htaccess files  
that are located underneath Zencart’s sub directories. Below is the  
.htaccess file located in the images directory. I can block with no  
problem, it’s allowing that I am having a problem with:

# 

# @copyright Copyright 2003-2010 Zen Cart Development Team

# @license [http://www.zen-cart.com/license/2\_0.txt](http://www.zen-cart.com/license/2_0.txt) GNU Public License

V2.0

# @version $Id: .htaccess 16111 2010-04-29 22:39:02Z drbyte $

# 

# This is used with Apache WebServers

# 

# The following blocks direct HTTP requests to all filetypes in this

directory recursively, except certain approved exceptions

# It also prevents the ability of any scripts to run. No type of

script, be it PHP, PERL or whatever, can normally be executed if  
ExecCGI is disabled.

# Will also prevent people from seeing what is in the dir. and any

sub-directories

# 

# For this to work, you must include either ‘All’ or at least: ‘Limit’

and ‘Indexes’ parameters to the AllowOverride configuration in your  
apache/conf/httpd.conf file.

# Additionally, if you want the added protection offered by the

OPTIONS directive below, you’ll need to add ‘Options’ to the  
AllowOverride list, if ‘All’ is not specified.

# Example:

#\<Directory “/usr/local/apache/htdocs”\>

# AllowOverride Limit Options Indexes

#  
###############################

# deny _everything_

\<FilesMatch “.\*”\>  
Order Allow,Deny  
Deny from all

# but now allow just _certain_ necessary files:

\<FilesMatch “.\*.(jpe?g|JPE?G|gif|GIF|png|PNG|swf|SWF)$” \>  
Order Allow,Deny  
Allow from all

IndexIgnore _/_

Thanks for any help you can give!

Brent

---

<div class="post-metadata">

**Author:** ![bwellsnc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e8cbc/32.png) [@bwellsnc](https://www.ruby-forum.com/u/bwellsnc)\
**Post date:** [September 14, 2012, 11:23pm UTC](https://www.ruby-forum.com/t/nginx-and-zencart/222778/2 "2012-09-14T23:23:58Z")

</div>

I have found the solution, even though it’s a pretty dirty one. Had  
to utilize if statements. If someone has a better solution, I would  
welcome it. Here is what is working:

server {  
listen 80;  
server\_name [example.com](http://example.com);  
access\_log /home/exampleusr/logs/example.com.access.log;  
error\_log /home/exampleusr/logs/example.com.error.log;  
root /home/exampleusr/public\_html;  
index index.html index.php index.htm;

location / {  
try\_files $uri $uri/ index.php;  
}

```
    location /docs {
            if ($request_uri ~*

```

(^/|.js|.css|.jpg|.gif|.png|.html)$ ) {  
break;  
}  
return 403;  
}

```
    location /editors {
            if ($request_uri ~*

```

(^/|.js|.css|.jpg|.gif|.png|.html|.xml)$ ) {  
break;  
}  
return 403;  
}

```
    location /email {
            if ($request_uri ~*

```

(^/|.jpg|.JPG|.jpeg|.JPEG|.gif|.GIF|.png|.PNG)$ ) {  
break;  
}  
return 403;  
}

```
    location /extras {
            if ($request_uri ~* (^\/|\.php|\.html)$ ) {
            break;
    }
            return 403;
    }

```

location /images {  
if ($request\_uri ~\*  
(^/|.jpg|.JPG|.jpeg|.JPEG|.gif|.GIF|.png|.PNG|.swf|.SWF|.WMA)$  
) {  
break;  
}  
return 403;  
}

```
    location /(download|pub) {
       if ($request_uri ~*

```

(^/|.zip|.ZIP|.gzip|.pdf|.PDF|.mp3|.MP3|.swf|.SWF|.wma|.WMA|.wmv|.WMV)$  
) {  
break;  
}  
return 403;  
}

```
   location /includes {
            if ($request_uri ~*

```

(^/|.js|.JS|.css|.CSS|.jpg|.JPG|.gif|.GIF|.png|.PNG|.swf|.SWF|.xsl|.XSL)$  
) {  
break;  
}  
return 403;  
}

```
   location /media {
            if ($request_uri ~*

```

(^/|.mp3|.mp4|.swf|.avi|.mpg|.wma|.rm|.ra|.ram|.wmv)$ ) {  
break;  
}  
return 403;  
}

```
   location /admin {
            if ($request_uri ~*

```

(^/|.php|.js|.css|.jpg|.gif|.png)$ ) {  
break;  
}  
return 403;  
}

location = /robots.txt {  
access\_log off;  
log\_not\_found off;  
}

location = /favicon.ico {  
access\_log off;  
error\_log off;  
log\_not\_found off;  
}

location ~ /. {  
access\_log off;  
log\_not\_found off;  
deny all;  
}

location ~ ~$ {  
access\_log off;  
log\_not\_found off;  
deny all;  
}

location ~\* .php$ {  
fastcgi\_param HTTPS on;  
fastcgi\_pass 127.0.0.1:9001;  
fastcgi\_index index.php;  
fastcgi\_split\_path\_info ^(.+.php)(.\*)$;  
include fastcgi\_params;  
fastcgi\_param SCRIPT\_FILENAME  
$document\_root$fastcgi\_script\_name;  
}

}
