New to nginx

Igor Sysoev is at rambler-co.ru
Sat Feb 28 15:52:53 MSK 2009


On Sat, Feb 28, 2009 at 04:21:56AM -0800, Ivan L. wrote:

> Hi,
> 
> I'm new to nginx, and I'm trying to configure it but I've some problems. I use Ubuntu 8.10, and I installed nginx 0.6.32(apt-get install nginx)
> 
> The problems I see;
> 
> - unknown directive "if($request_method"
> 
> If I remove these statements, the error I receive
> 
> - unknown directive "if(-d"
> 
> When I remove if(-d) statement, the error I receive;
> 
> - unknown directive "if(!-e)"

As it was already said, you need a space between "if" and "(":

     if (

However, your configuraiton is very strange.

> I've tried to configure it as described in the English wiki, and some blogs I've seen but I couldn't solve the problems. Can anyone help me?
> 
> Here's my /etc/nginx/sites-availabe/default config file;
> 
> 
> server {
>   listen 80;
>   client_max_body_size 50M;
>   client_body_buffer_size 128k;
>   charset utf-8;
>   
>   root /var/www/myweb;
>   index index.php index.html index.htm;
>   
>   access_log /var/log/nginx/access.log;
>   
>   location / {
>     if($request_method !~ GET) {
>       return 405;
>     }
>     if(-f $request_filename) {
>       break;
>     }
>     if(-d $request_filename) {
>       break;
>     }
>     if(!-e $request_filename) {
>       rewrite ^/search$ /index.php?where=search last;
>       rewrite ^/posts/([0-9])$ /index.php?posts=$1 last;
>       
>       break;
>     }
>   }

Why do you use "^/search$" ?

>   location /about {
>     if($request_method !~ GET) {
>       return 405;
>     }
>     if(!-e $request_filename) {
>       expires max;
>       rewrite ^/about$ /index.php?where=about break;
>     }
>   }

What do you expect here ?

>   location /contact {
>     if($request_method !~ ^(GET|POST)$) {
>       return 405;
>     }
>     if(!-e $request_filename) {
>       expires max;
>       rewrite ^/contact$ /index.php?where=contact break;
>     }
>   }

What do you expect here ?

>   location /downlods/ {
>     rewrite ^downloads/(.*)$ /downloads/$1 break;
>     return 403;
>   }

What do you expect here ?

>   location ~* ^.+\.(jpg|jpeg|gif|png|css|js)$ {
>     expires 30d;
>   }
>   
>   error_page   500 502 503 504  /50x.html;
>   location = /50x.html {
>     root   /var/www/myweb;
>   }
>     
>   location ~ \.php$ {
>     fastcgi_pass   127.0.0.1:9000;
>     fastcgi_index  index.php;
>     fastcgi_param  SCRIPT_FILENAME  /var/www/myweb$fastcgi_script_name;
>     include fastcgi_params;
>   }
>   
> }


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list