Ez vs NginX howto

Author Message

Aprilia Kartika

Friday 17 April 2009 2:16:28 am

Dear all,

some days ago I tried to run Ez Publish based on nginx.
but till now i still have a same problem:

NginX just like doesn't recognise index.php that contained by Ez.
the result are:

404 - not found

I think it is because of it's rewrite rules. but I dont sure.

I am appreciate if one of you would like to post your nginx configuration with rewrite rules.
and thanks for your kind attentions, and I am so sorry for my English that is not so good.

cheers
Kartika

Andreas Kaiser

Friday 17 April 2009 4:08:02 am

It should be because of rewrite rules used in nginx. In this post there are some references to nginx and lighttpd: http://ez.no/developer/forum/suggestions/memcache (but no reference how the rewrite rules should be in nginx...)

I also check nginx documentation, mailing list or google for possible solutions: I found this blog post about converting .htaccess rewrite rules to nginx configuration: http://blog.taragana.com/index.php/archive/nginx-hacking-tips/

eZ Partner in Madrid (Spain)
Web: http://www.atela.net/

Bruno Chirez

Tuesday 21 April 2009 8:30:19 am

Could you show us your nginx.conf ?

http://www.sn4rky.com

Aprilia Kartika

Friday 01 May 2009 1:52:41 am

my nginx.conf like shown below:

============= begin =================
user web web;
worker_processes 15;
error_log /opt/nginx/logs/error.log;
worker_rlimit_nofile 8192;
events {
worker_connections 4096;
use epoll;
}

http {
include mime.types;
default_type application/octet-stream;
include /opt/nginx/conf/extra/proxy.conf;
client_max_body_size 64m;

log_format main '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

keepalive_timeout 65;
sendfile on;
tcp_nopush on;
tcp_nodelay off;
server_names_hash_bucket_size 128;

gzip on;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/html text/css text/js application/x-javascript application/javascript text/xml application/xml application/xml+rss text/javascript;

server { # ez publish;
listen 80;
server_name www.buzzme.com buzzme.com;

charset utf-8;

access_log /var/log/nginx/akses.log;
error_log /var/log/nginx/error.log;

location / {
root /datas/web;
index index.html index.php;
include /opt/nginx/conf/rewrite.conf;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /datas/web;
}

location ~ ^/(images|javascript|js|css|flash|media|static)/ {
root /datas/web;
expires 30d;
}

location ~ \.php($|/) {
set $script $uri;
set $path_info "";

if ($uri ~ "^(.+\.php)(/.+)") {
set $script $1;
set $path_info $2;
}

fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /datas/web$fastcgi_script_name;
fastcgi_param PATH_INFO $path_info;
include /opt/nginx/conf/fastcgi_params;

}
}
}

}
=================== end ======================

while my rewrite.conf shown below:

====================== begin ====================

rewrite ^/content/treemenu/? /index_treemenu.php last;
rewrite ^/index_treemenu.php - last;
rewrite !\.(gif|jpe?g|png|css|js|swf|html)|var(.+)storage.pdf(.+)\.pdf$ /index.php last;
break;

====================== end =====================

i tried again my config yesterday and i got a lot of strange symbols like (?) and numbers.
i don't have any idea for this things.

any advice?

--
thank you

Gaetano Giunta

Monday 21 September 2009 7:50:57 am

Here's a working config:
- plain nginx.conf includes a 2nd file within its 'httpd' section
- the 2nd file is the following, configured for vhost mode, non-ezp-clustered:

server {

    listen       80;
    # to be tailored...
    server_name  ezp.local ezp-admin.local;

    # this one too...
    root   /var/www/eZPublish;
    index  index.php;

    # default match
    # nb: this location is used to match anything that
    # does not match a regexp location below
    location / {
        # pipe everything via index.php
        # doing it directly here instead of using a rewrite saves
        # a 2nd match on the url...
        #rewrite ^.*$ /index.php last;
        # this assumes php is listening in fcgi mode on port 10000...
        fastcgi_pass   127.0.0.1:10000;
        fastcgi_param  SCRIPT_FILENAME  /var/www/eZPublish/index.php;
        include        fastcgi_params;
    }

    location ~ ^/content/treemenu {
         fastcgi_pass   127.0.0.1:10000;
         fastcgi_param  SCRIPT_FILENAME  /var/www/eZPublish/index_treemenu.php;
         include        fastcgi_params;
    }

    # serve all images/css/js/ico,... and public videos directly
    location ~* \.(gif|jpe?g?|png|css|js|swf|pdf|html?|ico)$ {
        ## @todo: add expires headers...
        # favicon is only stored in 1 dir, the design one; But browsers ask for it in the root
        rewrite ^/favicon\.ico$ /design/standard/images/favicon.ico last;
    }

    # direct access to robots.txt
    location = /robots.txt {
    }

}

Principal Consultant International Business
Member of the Community Project Board

Gaetano Giunta

Thursday 15 October 2009 2:58:10 am

And here's one that is fine for non-vhost setups:

### eZ Publish non-vhost config for Nginx + php fastcgi
###
### to make it work, set in settings/override/site.ini.append.php :
### [SiteAccessSettings]
### ForceVirtualHost=true
### MatchOrder=uri
###
### the resulting url will be http://server.name/siteaccess

server {
        listen             80;

        ### change these 3 lines for your local install ###
        server_name        localhost;
        set $ezp_root      /var/www/ezpublish;
        set $fastcgi_port  10000;

        root   $ezp_root;
        index  index.php;

        # all things matched by a regexp below will not be matched here
        # and thus tunnelled into index.php
        location / {
            rewrite ^(.*)$ /index.php?$1 last;
        }

        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:$fastcgi_port;
            fastcgi_param  SCRIPT_FILENAME  $ezp_root/index.php;
            include        fastcgi_params;
        }

        # treemenu takes advantage of a specialized controller
        location ~ ^/content/treemenu {
            fastcgi_pass   127.0.0.1:$fastcgi_port;
            fastcgi_param  SCRIPT_FILENAME  $ezp_root/index_treemenu.php;
            include        fastcgi_params;
        }

        # serve all images/css/js/ico/... directly
        # nb: for extra precision we might want to match based on the beginning of the path here,
        # as using a weird url such as eg. user/login/(offset)/.ico will result in a 404 error
        location ~* \.(gif|jpe?g?|png|css|js|swf|pdf|html?|ico)$ {
            ## @todo: add expires headers for better scalability...
            # favicon is only stored in 1 dir, the design one; But browsers ask for it in the root
            rewrite ^/favicon\.ico$ /design/standard/images/favicon.ico last;
        }

        # direct access to robots.txt
        location = /robots.txt {
        }

        # direct access to p3p related files
        #location ~ ^/p3p/(.+)\.xml$ {
        #}
}

Principal Consultant International Business
Member of the Community Project Board

Boris HUISGEN

Tuesday 20 October 2009 4:11:32 am

This is my working configuration :

    server {
     listen       80;
     server_name  ezpublish.bhuisgen.my.domain;
     root /Users/bhuisgen/Sites/ezpublish/www/html;
     index index.php;

     if (!-f $request_filename) {
        rewrite ^(.*)$ /404;
     }

     location ~ "^/[^/]*\.php$" {
        set $script "index.php";

        if ( $uri ~ "^/(.*\.php)" ) {
           set $script $1;
        }

        fastcgi_pass   unix:/opt/local/var/run/nginx/fcgi-php.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME /Users/bhuisgen/Sites/ezpublish/www/html/$script;
        include        fastcgi_params;
     }

     location / {
        rewrite "^/var/storage/(.*)$" "/var/storage/$1" break;
        rewrite "^/var/([^/]+)/storage/(.*)$" "/var/$1/storage/$2" break;
        rewrite "^/var/cache/texttoimage/(.*)$" "/var/cache/texttoimage/$1" break;
        rewrite "^/var/([^/]+)/cache/texttoimage/(.*)$" "/var/$1/cache/texttoimage/$2" break;
        rewrite "^/design/([^/]+)/(stylesheets|images|javascript)/(.*)$" "/design/$1/$2/$3" break;
        rewrite "^/share/icons/(.*)$" "/share/icons/$1" break;
        rewrite "^/extension/([^/]+)/design/([^/]+)/(stylesheets|images|javascripts|javascript|flash?)/(.*)$" \
           "/extension/$1/design/$2/$3/$4" break;
        rewrite "^/packages/styles/(.+)/(stylesheets|images|javascript)/([^/]+)/(.*)$" \
           "/packages/styles/$1/$2/$3/$4" break;
        rewrite "^/packages/styles/(.+)/thumbnail/(.*)$" "/packages/styles/$1/thumbnail/$2" break;
        rewrite "^/favicon\.ico$" "/favicon.ico" break;
        rewrite "^/robots\.txt$" "/robots.txt" break;
        rewrite "^/var/cache/debug.html(.*)$" "/var/cache/debug.html$1" break;
        rewrite "^/var/([^/]+)/cache/public/(.*)$" "/var/$1/cache/public/$2" break;
        rewrite "^/var/([^/]+)/cache/debug\.html(.*)$" "/var/$1/cache/debug.html$2" break;

        rewrite "^/content/treemenu/?$" "/index_treemenu.php" last;
        rewrite "^(.*)$" "/index.php?$1" last;
     }

    }

http://blog.hbis.fr/2009/10/20/nginx-ezpublish/

Roman Kushalov

Wednesday 07 April 2010 6:41:30 am

Hi all,

I have a working properly eZP with Apache2.2.14. And I want to install and configure Nginx as frontend for eZP + FastCGI (listen port 9000)

My nginx.conf:

user www-data;
worker_processes 2;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
# multi_accept on;
}
http {
include /etc/nginx/mime.types;
access_log /var/log/nginx/access.log;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 3;
tcp_nodelay off;
gzip on;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
#gzip_disable "MSIE [1-6]\.(?!.*SV1)";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}

My /sites-enabled/site.com file:

server {
listen 80;
server_name site.amazonaws.com www.site.amazonaws.com;
rewrite ^/(.*) http://site.amazonaws.com/$1 permanent;
location / {
proxy_pass http://127.0.0.1:81/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
location ~* \.(jpeg|jpg|gif|png|css|js|pdf|txt|tar)$

{
root /var/www/site;
index index.php;
}
}

My Apache listen port 127.0.0.1:81

My Apache's /sites-enabled/site.com

<VirtualHost _default_:81>
DocumentRoot "/var/www/site"
ServerName site.amazonaws.com
ServerAlias www.site.amazonaws.com
<Directory "/var/www/site">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault A600
ExpiresByType image/gif "access plus 1 day"
ExpiresByType image/jpeg "access plus 1 day"
ExpiresByType image/png "access plus 1 day"
ExpiresByType image/x-icon "access plus 1 day"
ExpiresByType text/css "access plus 2 day"
ExpiresByType text/js "access plus 2 day"
ExpiresByType text/javascript "access plus 2 day"
ExpiresByType application/x-javascript "access plus 2 day"
<FilesMatch "\.(php|php4)$">
ExpiresByType text/html "now"
</FilesMatch>
</IfModule>
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.avi$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.mov$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.mp3$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.mp4$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.rm$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.swf$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.fla$ no-gzip dont-vary

AddOutputFilterByType DEFLATE image/svg+xml

AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE application/x-httpd-eruby
AddOutputFilterByType DEFLATE text/html
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC]
RewriteRule ^(.*) http://%1$1 [R=301,L]
# RewriteRule content/treemenu/?$ /index_treemenu.php - [L]
# RewriteRule ^blog/ /blog/index.php [R=301,L]
RewriteRule ^/webalizer/[^/].* - [L]
RewriteRule ^/phpmyadmin/[^/].* - [L]
RewriteRule ^/doc/[^/].* - [L]
RewriteRule ^/xml/[^/].* - [L]
RewriteRule ^/var/storage/.* - [L]
RewriteRule ^/var/[^/]+/storage/.* - [L]
RewriteRule ^/var/cache/texttoimage/.* - [L]
RewriteRule ^/var/[^/]+/cache/texttoimage/.* - [L]
RewriteRule ^/design/[^/]+/(stylesheets|images|javascript)/.* - [L]
RewriteRule ^/share/icons/.* - [L]
RewriteRule ^/extension/[^/]+/design/[^/]+/(stylesheets|images|javascripts?)/.* - [L]
RewriteRule ^/packages/styles/.+/(stylesheets|images|javascript)/[^/]+/.* - [L]
RewriteRule ^/packages/styles/.+/thumbnail/.* - [L]
RewriteRule ^/favicon\.ico - [L]
RewriteRule ^/jpg/[^/].* - [L]
RewriteRule ^/gif/[^/].* - [L]
RewriteRule ^/images/[^/].* - [L]
RewriteRule ^/robots.txt - [L]
RewriteRule ^/Sitemap.xml - [L]
# Uncomment the following lines when using popup style debug.
RewriteRule ^/var/cache/debug\.html.* - [L]
RewriteRule ^/var/[^/]+/cache/debug\.html.* - [L]
# RewriteRule content/treemenu/? index_treemenu.php [L]
# RewriteRule index_treemenu.php - [L]
RewriteRule vizerra-banner-1.2.swf - [L]
RewriteRule !\.(gif|jpe?g|png|css|js|html?)|var(.+)storage.pdf(.+)\.pdf$ index.php
RewriteRule ^/var/[^/]+/cache/(stylesheets|images|javascripts?)/.* - [L]
RewriteRule ^/var/[^/]+/cache/public/.* - [L]
RewriteRule ^visual$ index.php/visual
RewriteRule content/treemenu/? index_treemenu.php
# RewriteRule ^/kernel/classes/packagehandlers/ezcontentclass/index_treemenu_custom.php - [L]
RewriteRule index_treemenu.php - [L]
RewriteRule .* /index.php
</IfModule>
</VirtualHost>

When I trying to go to http://site.amazonaws.com, I see only "Welcome to Nginx" or,

if I delete /etc/nginx/sites-enabled/@default -

"The server has determined that the request will never be completed"

Help me, please, tnx

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.