• Welcome to the Chevereto user community!

    Here users from all over the world gather around to learn the latest about Chevereto and contribute with ideas to improve the software.

    Please keep in mind:

    • 😌 This community is user driven. Be polite with other users.
    • 👉 Is required to purchase a Chevereto license to participate in this community (doesn't apply to Pre-sales).
    • 💸 Purchase a Pro Subscription to get access to active software support and faster ticket response times.

Use default static pages for error handling

Rodolfo

⭐ Chevereto Godlike
Chevereto Staff
Administrator
In some sites it may be a problem to use PHP to render the system errors like the not found error (404). This is because PHP is used to render this error pages which means PHP + Database usage on a simple page load.

Now, as you may know there is a way to use a image replacement (since Chevereto 2.3) to handle this:
Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule images/.+\.(gif|jpe?g|png|bmp) content/system/img/404.gif [NC,L]

Which is cool to show a image "Not found" replacement and also promote your site. Problem comes when people use this PHP error handling to do a DDoS Layer 7 attack on your server, so imagine that they embed js, css, or any file... The system will be collapsed because PHP will be serving that request instead of the server default error page.

To prevent this, you can do the following... Open the root .htaccess file and above this:
Code:
RewriteRule . index.php [L]

Add this:
Code:
RewriteCond %{REQUEST_URI} !\.([a-z]{1,4})$ [NC]

The whole rule will read: For anything that is not a file, is not a directory, and the request URL doesn't contain .ext (like txt, js, asdf) Chevereto will send the request to the bootstrap (index.php), else... The system will issue the default error page. Cool isn't?

I will issue this improvement with 2.5 and you should apply it now. I've already applied on the demo if you want to test: http://demo.chevereto.com/images/2012/11/04/MdsaDiIL.js http://demo.chevereto.com/images/2012/11/04/MdsaDiIL.png

The complete .htaccess looks like this:
Code:
# Disable server signature
ServerSignature Off
 
# Disable directory listing (-indexes), Multiviews (-MultiViews) and enable Follow system links (+FollowSymLinks)
Options -Indexes
Options -MultiViews
Options +FollowSymLinks
 
# Turn on mod_rewrite
RewriteEngine On
 
# If you have problems with the rewrite rules remove the "#" from the following RewriteBase line
# You will also have to change the path to reflect the path to your Chevereto installation
#RewriteBase /chevereto
 
# The /api rewrite
RewriteRule ^api$ api.php [L]
 
# If you want to have your own fancy "image not found" image remove the "#" from RewriteCond and RewriteRule lines
# Make sure to apply the correct paths to reflect your current installation
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule images/.+\.(gif|jpe?g|png|bmp) content/system/img/404.gif [NC,L]
 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.([a-z]{1,4})$ [NC]
RewriteRule . index.php [L]
 
How that rule could be for Nginx ?
thanks!

Try to use nginx with apache (proxy setup) or use Litespeed. In that setups you won't need to do special rewrites to understand the .htaccess rules
 
On a 128mb ram vps im running nginx+php+mysql
right now the usage is 48mb ram :D
You could image if i put apache too? no thanks :D
 
On a 128mb ram vps im running nginx+php+mysql
right now the usage is 48mb ram :D
You could image if i put apache too? no thanks :D
...

Nginx is all about request handling, not less memory consume. Of course that you notice that it uses less memory because nginx handles better the request than apache but that's all... Why you think that nginx is so widely used? Is because it can optimize the request handling for apache, not because their short amount of modules or less things that it does... Everybody knows that aside the request handling Apache is way better.

So what if you can get Apache with a better request handling? Sure... the name of that is Litespeed but that is not free so the alternative is nginx+apache.

Nginx alone should be only used by people who know how to highly tune a server because is hard to setup a real working server compatible with Apache and I'm not even mention the security issues that nginx has.
 
My chevereto website is powered by pure nginx, all things working, api upload too :D
I've followed your tutorial to put my website on cloudflare, so now its like:
Cloudflare => Nginx
all working fine :p
About what security are you talking about? be more clear please?
 
Back
Top