Nginx and Zencart

bwellsnc bwellsnc at gmail.com
Fri Sep 14 21:23:28 UTC 2012


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;
    	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;
     	}
	
}




On Mon, Sep 10, 2012 at 8:16 AM, bwellsnc <bwellsnc at gmail.com> wrote:
> 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 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
> #</Directory>
> ###############################
>
> # deny *everything*
> <FilesMatch ".*">
>   Order Allow,Deny
>   Deny from all
> </FilesMatch>
>
> # but now allow just *certain* necessary files:
> <FilesMatch ".*\.(jpe?g|JPE?G|gif|GIF|png|PNG|swf|SWF)$" >
>   Order Allow,Deny
>   Allow from all
> </FilesMatch>
>
> IndexIgnore */*
>
>
>
> Thanks for any help you can give!
>
> Brent



More information about the nginx mailing list