• Welcome to the Chevereto User Community!

    Here, users from all over the world come together to learn, share, and collaborate on everything related to Chevereto. It's a place to exchange ideas, ask questions, and help improve the software.

    Please keep in mind:

    • This community is user-driven. Always be polite and respectful to others.
    • Support development by purchasing a Chevereto license, which also gives you priority support.
    • Go further by joining the Community Subscription for even faster response times and to help sustain this space
  • Chevereto Support CLST

    Support response

    Support checklist

    • Got a Something went wrong message? Read this guide and provide the actual error. Do not skip this.
    • Confirm that the server meets the System Requirements
    • Check for any available Hotfix - your issue could be already reported/fixed
    • Read documentation - It will be required to Debug and understand Errors for a faster support response

Nginx working Rewrite Rules

Bruno.GJ

banned
Code:
location / {
if (-f $request_filename/index.html){
                rewrite (.*) $1/index.html break;
        }
if (-f $request_filename/index.php){
                rewrite (.*) $1/index.php;
        }
if (!-f $request_filename){
                rewrite (.*) /index.php;
        }
        try_files $uri $uri/ /api.php;
}
 
location /admin {
                try_files $uri /admin/index.php?$args;
        }

I hope they work for you too, I used nginx 1.0.10 + php-fpm
cheers 😀

The admin area working as it should, the api works and let me upload remotely with a firefox addon.
 
confirmed to work on nginx 1.2.2 🙂
thanks for the like Rodolfo!

This is my Full domain setup, ofcourse adapt it for your own!


Code:
server
    {
        listen      80;
        server_name yourdomain.org www.yourdomain .org;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/www.yourdomain.org;
 
        if ($host = 'www.yourdomain.org' ) {
        rewrite  ^/(.*)$  http://yourdomain.org/$1  permanent;
        }     
     
        location / {
        if (-f $request_filename/index.html){
                rewrite (.*) $1/index.html break;
        }
        if (-f $request_filename/index.php){
                rewrite (.*) $1/index.php;
        }
        if (!-f $request_filename){
                rewrite (.*) /index.php;
        }
        try_files $uri $uri/ /api.php;
        }
 
        location /admin {
        try_files $uri /admin/index.php?$args;
        }
 
      location ~ .*\.(php|php5)?$
            {
                fastcgi_pass  unix:/tmp/php-cgi.sock;
                fastcgi_index index.php;
                include fcgi.conf;
            }
 
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
            {
                expires      8d;
            }
 
        location ~ .*\.(js|css)?$
            {
                expires      8d;
            }
 
        #log_format  www.yourdomain.org  '$remote_addr - $remote_user [$time_local] $request '
        #    '$status $body_bytes_sent $http_referer '
        #    '$http_user_agent $http_x_forwarded_for';
        #access_log  /home/wwwlogs/www.yourdomain.log  www.yourdomain.org;
    }
I disabled the logs, just for testing purposes.
I hope this will help someone 🙂
 
With this the api was not working for me.

I removed
Code:
try_files $uri $uri/ /api.php;

And used:
Code:
        location /api {
        try_files $uri /api.php?$args;
        }
 
I need this rewrite:

RewriteRule ^images/(\w*\.)(jpg|png|gif)$ images/old/$1$2 [L] #legacy images
 
The above by Bruno didn't work for me as it resulted in a 'redirect loop' error.

This worked for me:

Code:
server
    {
        listen 80;
        server_name example.com www.example.com;
        root  /usr/share/nginx/www/chevereto;
 
        if ($host = 'example.com' ) {
        rewrite  ^/(.*)$  http://www.example.com/$1  permanent;
        }
 
        location /
        {
        index index.html index.htm index.php;
 
        if (!-e $request_filename)
        {rewrite (.*) /index.php last;}
 
        try_files $uri $uri/ /index.php;
        }
 
 
        location ~ .*\.(php|php5)?$
        {
        fastcgi_pass  unix:/tmp/php5-fpm.sock; #change to fastcgi_pass 127.0.0.1:9000 if you don't have this enabled in [SIZE=14px][FONT=Ubuntu Mono][COLOR=#222222]/etc/php5/fpm/pool.d/www.conf[/COLOR][/FONT][/SIZE]
        fastcgi_index  index.php;
        include /etc/nginx/fastcgi_params;
        }
 
        location /admin {
        try_files $uri /admin/index.php?$args;
        }
 
 
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
            {
                expires      8d;
            }
 
        location ~ .*\.(js|css)?$
            {
                expires      8d;
            }
 
 
}

Some notes:
1. please change example.com to your domain
2. The root address might be different for your site
3. I'm using php5-fpm.sock. If you are not, change it to fastcgi_pass 127.0.0.1:9000

I'm on Amazon EC2 (Ubuntu 12.04 LTS) Nginx (1.1.19) + php5-fpm + APC.
If you are on the same setup, your for NGINX should be 1.1.19 if you package it from apt-get.

I'm still testing it out but everything seems okay for now. Let me know if you run into any problems.

Cheers~
 
when I change nginx rules to
Code:
location / {
try_files $uri $uri/ /api.php;
}
I got this:
{"status_code":403,"status_txt":"Invalid API key"}​

when I change nginx rules to
Code:
location /api {
try_files $uri /api.php?$args;
}
I got a 404 page.
 
http://wiki.nginx.org/IfIsEvil

Code:
location / {
    index index.php;
    try_files $uri $uri/ /index.php;
}

location /admin {
    try_files $uri /admin/index.php?$args;
}

location /api {
    try_files $uri /api.php?$args;
}

location ~ includes {
    internal;
    return 404;
}

location ~ \.(bmp|gif|jpe?g|png)$ {
    try_files $uri /content/system/img/404.gif;
}

location ~ \.php$ {
    ...
}
 
Last edited:
Chevereto 3 rewrite rules

Code:
    location / {
      try_files $uri $uri/ /index.php?$args;
    }
    location ~ ^/(images)/ {
    try_files $uri /content/system/404.gif;
    expires 1y;
    add_header    Pragma public;
    add_header  Cache-Control public;
    add_header  Last-Modified "";
    add_header  ETag "";
    break;
}
 
Thank you vlaur. I got it working by using the rewrite rules of Pavel_M, but I'll give yours a shot as well 😉.
 
For those who might have read my previous post, go with vlaur's rewrite rules for Chev v3, the other ones don't work properly.
 
I've tried a several iterations of this nginx rewrite rules and I get a system error page stating it can't find the root .htaccess file. I'd appreciate some assistance getting the correct nginx config. Thanks in advance!

server
{
listen 80;
server_name imgscrap.com www.imgscrap.com;
root /usr/share/nginx/html;

if ($host = 'imgscrap.com' ) {
rewrite ^/(.*)$ http://www.imgscrap.com/$1 permanent;
}

# location /
# {
# index index.html index.htm index.php;
#
# if (!-e $request_filename)
# {rewrite (.*) /index.php last;}
#
# try_files $uri $uri/ /index.php?$query_string;
# }

location ~ .*\.(php|php5)?$
{
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}

location /admin {
try_files $uri /admin/index.php?$args;
}


location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 8d;
}

location ~ .*\.(js|css)?$
{
expires 8d;
}

location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ ^/(images)/ {
try_files $uri /content/system/404.gif;
expires 1y;
add_header Pragma public;
add_header Cache-Control public;
add_header Last-Modified "";
add_header ETag "";
break;
}
}
 
I've looked at this several times and tried setting up my config several different ways. Having a full example is your documentation would be greatly appreciated for noobs.
 
Back
Top