Clear the un-clear for me !

Ma Ma lists at ruby-forum.com
Fri Jun 4 15:00:20 MSD 2010


Hello everyone ,
First of all , I would like to thanks Igor and his team for this real
nice web server which can take a huge of work in less resources and fast
speed .

I hope to get the answers for my questions as i need this answers to
complete my work .

My questions:-
1.How i can set a 404 image instead of page , what i means if for
example some one goes for un-exist image url
(http://www.example.com/flk123j12l31.gif) so how i tell nginx to
redirect him to (http://www.example.com/notfound.jpg) , i try to use
this rules , I try to use this rules but it not help .

  location ~ /(upload/Pictures|upx/uploads)/.* {

valid_referers none block server_names ~(example.com|google|lll1.com);
 if ($invalid_referer) {
  error_page 404 = /notfound.gif;
rewrite  ^(.*)$ /leech.gif break;
}
}

2.How i can put multiple files in if statement .

What i have now

if ($request_filename ~ "showthread.php$" ) {
rewrite ^/vb/(.*)$ /vb/vbseo.php last;
}
if ($request_filename ~ "external.php$" ) {
rewrite ^/vb/(.*)$ /vb/vbseo.php last;
}

if ($request_filename ~ "archive/index.php$" ) {
rewrite ^/vb/(.*)$ /vb/vbseo.php last;
}


What i would like to have and works

if ($request_filename ~ (archive/index|external|showthread).php$) {
rewrite ^/vb/(.*)$ /vb/vbseo.php last;
}

4.Does it give a performance boost when i set workers equals to cores
numbers?

5.What your advices about my images server nginx file.

user  nobody;
# no need for more workers in the proxy mode
worker_processes  16;
worker_priority -5;

#error_log  logs/error.log info;

worker_rlimit_nofile 65536;

events {
worker_connections  2024; # you might need to increase this setting for
busy servers
use epoll;
}

http {
 server_names_hash_max_size 2048;



types {
    text/html                             html htm;
    text/css                              css;
    text/xml                              xml;
    image/gif                             gif;
    image/jpeg                            jpeg jpg;
    application/x-javascript              js;

    text/plain                            txt;

    image/png                             png;
    image/x-icon                          ico;
    image/x-jng                           jng;
    image/x-ms-bmp                        bmp;

    application/pdf                       pdf;
    application/x-rar-compressed          rar;
    application/x-shockwave-flash         swf;
    application/zip                       zip;

    application/octet-stream              bin exe dll;
    application/octet-stream              iso img;

}


default_type  application/octet-stream;

sendfile on;
#tcp_nopush on;
tcp_nodelay on;
server_tokens           off;
keepalive_timeout  4;
gzip on;
gzip_min_length  1100;
gzip_buffers  4 32k;
gzip_types    application/x-javascript text/css;
gzip_http_version 1.1;
ignore_invalid_headers on;
gzip_comp_level 9;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
client_header_timeout  6m;
client_body_timeout 6m;
send_timeout     6m;
connection_pool_size  256;
client_header_buffer_size 4k;
large_client_header_buffers 4 32k;
request_pool_size  4k;
output_buffers   32 64k;
postpone_output  1460;
client_body_buffer_size      1024k;
client_max_body_size         128m;
#Vhost Start

index index.php index.html index.htm;

server {
error_page 404 = /404.php;
access_log off;
#error_log  logs/vhost-#error_log warn;

listen    207.102.41.120:80;
server_name  atm.example.com;
root /home/example/public_html/files;
location ~* \.(gif|jpg|jpeg|png|ico)$ {
expires 40d;
add_header Cache-Control public;
 }

# location ~ ^/atm/.*\.php$ {
#deny all;
#}

location ~ /(atm|includes)/.*\.php$ {
deny all;
}





location ~ \.php$ {
try_files $uri /404.php;
fastcgi_param  SCRIPT_FILENAME
/home/example/public_html/atm$fastcgi_script_name;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_index  index.php;
fastcgi_buffer_size 128K;
fastcgi_read_timeout         120;
fastcgi_buffers 64 96k;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/0.7.65;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;
fastcgi_pass  127.0.0.1:9000;

}
}



server {
access_log off;
error_page 404 = /404.php;
#error_log  logs/vhost-#error_log warn;
listen    207.102.41.120:80;
server_name  images.example.com;
root   /home/example/public_html/images;


location ~* \.(gif|jpg|jpeg|png|js|css|ico|swf)$ {
expires 40d;
add_header Cache-Control public;
valid_referers none block server_names
~(example.com|google.|.lll1.com|localhost);
if ($invalid_referer) {
#error_page 404 = /ngvaild.gif;
rewrite  ^(.*)$ /ngvaild.gif break;
}
}



location ~ \.php$ {
try_files $uri /404.php;
fastcgi_param  SCRIPT_FILENAME
/home/example/public_html/images$fastcgi_script_name;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_index  index.php;
fastcgi_buffer_size 32K;
fastcgi_read_timeout         60;
fastcgi_buffers     64 4k;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/0.7.65;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;
fastcgi_pass  127.0.0.1:9000;}

}




server {
access_log off;
error_page 404 = /404.php;
#error_log  logs/vhost-#error_log warn;
listen    207.102.41.120:80;
server_name  up.example.com www.up.example.com;
root   /home/example/public_html/up;
location ~* \.(gif|jpg|jpeg|png|js|css|ico|swf)$ {
#error_page 404 = /ngvaild.gif;
expires 40d;
add_header Cache-Control public;
valid_referers none block server_names ~(example.com|google.|.lll1.com);
if ($invalid_referer) {
error_page 404 = /ngvaild.gif;
rewrite  ^(.*)$ /ngvaild.gif break;
}
}

location ~ \.php$ {
try_files $uri /404.php;
fastcgi_param  SCRIPT_FILENAME
/home/example/public_html/up$fastcgi_script_name;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_index  index.php;
fastcgi_buffer_size 16K;
fastcgi_read_timeout         90;
fastcgi_buffers     64 4k;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/0.7.65;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;
fastcgi_pass  127.0.0.1:9000;}
}
}




Your help and effort is much appereciated and i really hope to get help
as soon as possible .

Thanks ,
M-A-G
-- 
Posted via http://www.ruby-forum.com/.



More information about the nginx mailing list