help to config nginx

pepejose nginx-forum at nginx.us
Wed Sep 2 18:50:33 MSD 2009


hello, (sorry for my English)

	
I'm testing nginx as a proxy in front of apache.

this is my config file....


user  apache apache;
worker_processes  1;

#log levels [ debug | info | notice | warn | error | crit ]  
	error_log  /usr/local/nginx/logs/error.log notice;

pid        /usr/local/nginx/logs/nginx.pid;

events {
    worker_connections  1024;
}

http{
    include       mime.types;
    default_type  application/octet-stream;
	
	#Timeouts and KeepAlive
		keepalive_timeout  4 4;
		keepalive_requests 100;
	#General Options
		sendfile           on;
		server_tokens      off;
		autoindex 		   off;
		client_max_body_size 10m;
		
	#TCP options  
		tcp_nodelay on;
		tcp_nopush  off;

	#Compression
		gzip              on;
		gzip_comp_level   6;
		gzip_proxied off;
		gzip_vary    off;
		gzip_types text/plain text/xml application/x-javascript text/css;

	#Log Format
		log_format  main  '$remote_addr $host $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" "$http_user_agent" "$gzip_ratio"';

    server {
		listen *:80;
        server_name  --------;
		root /---------/;
		index index.php index.html index.htm;
        access_log  /usr/local/nginx/logs/access.log  main;	
							
		location ~ /\.ht {
			deny  all;
		}	
		
		location ~ \.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf|avi|mp3)$ {
			expires 30d;
			break;
		}
		
		#rules mod rewrite
		
		rewrite "^/noticia/([0-9\\\*]{1,20})/(.*)$" /noticia.php?id=$1 last;
		rewrite "^/noticia-lectores/([0-9\\\*]{1,20})/(.*)$" /part_noticia.php?id=$1 last;
		rewrite "^/cartas/([0-9\\\*]{1,20})/(.*)$" /part_carta.php?id=$1 last;
		rewrite "^/galeria/([0-9\\\*]{1,20})/(.*)$" /galeria.php?id=$1&idfoto=$2 last;
		rewrite "^/enimagenes/([0-9\\\*]{1,20})/(.*)$" /part_enimagen.php?id=$1&idfoto=$2 last;
		rewrite "^/galeria_usuario/([0-9\\\*]{1,20})/(.*)$" /galeria_usuario.php?id=$1&idfoto=$2 last;
		rewrite "^/utiles/([0-9\\\*]{1,20})/(.*)/$" /utiles.php?seccion=$1 last;
		rewrite "^/pregunta/([0-9]{1,20})/$" /part_pregunta.php?idpregunta=$1 last;
		rewrite "^/debates/(.*)$" /part_debateslocales.php?tipo=$1 last;
		rewrite "^/usuarios/perfil/([0-9]{1,20})$" /usuarios/perfil.php?idusuario=$1 last;
		rewrite "^/videoslectores/([0-9]{1,20})$" /videoslectores2.php?id=$1 last;
		rewrite "^/opinion/([0-9\\\*]{1,20})/$" /noticia_opinion.php?id=$1 last;
				
        #Proxy the PHP scripts to Apache listening on 127.0.0.1:8080
        location ~ \.php$ {
			proxy_set_header Host $host;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_buffering off;
			if ($request_uri ~ /resize.php){
				expires 30d;
			}
			proxy_pass   http://127.0.0.1:8080;
        }		
	}

}



well:

-- some images from my website, I resize with php, and if I not disable proxy_buffering does not load entire, just the beginning, about 1 / 3 to 1 / 2 of the image (the same as this http://www.eglx.com/J/bug.JPG), because this happens to activate the proxy_buffering (proxy_buffering on)? any help?

-- I read something about the header "X-Accel-Redirect" then, I wonder if I can use to get something like this:
http://kovyrin.net/wp-content/uploads/2006/05/algorithm_c.png  because in my resize.php not resize some images, simply do  header("Content-type: image/gif"); readfile($pic);

	
thank you very much!!!

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,5471,5471#msg-5471






More information about the nginx mailing list