cgi files in plain text

brianmercer nginx-forum at nginx.us
Wed May 11 03:07:36 MSD 2011


jeanjan Wrote:
-------------------------------------------------------
> Hi,
> 
> I installed nginx and php5-fpm from repositories
> on ubuntu 10.04.
> everything works well. The phpinfo test file
> works.
> 
> I try to access collection (for collectd) pages.
> When I access the url of the
> collection3/bin/index.cgi, I can see the file in
> plain text.
> 
> This is the config file used :
> server {
>     listen   80;
>     server_name  toto.com;
>     access_log 
> /var/log/nginx/localhost.access.log;
> 
> ## Default location
>     location / {
>         root   /var/www;
>         index  index.php;
> 	try_files $uri $uri/ /index.php?q=$uri&$args;
> 	auth_basic            "Restricted";
> 	auth_basic_user_file  /var/htpasswd_au1;
> 
>     }
> 
> # Protection
> #location = /var/www {
> #  auth_basic            "Restricted";
> #  auth_basic_user_file  /var/htpasswd_au1;
> #}
> 
> ##    try_files $uri $uri/ /index.php?q=$uri;
> ## Images and static content is treated different
>     location ~*
> ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
>       access_log        off;
>       expires           30d;
>       root /var/www;
>     }
> 
> 
> 
> ## Parse all .php file in the /var/www directory
>     location ~ .php$ {
>         fastcgi_split_path_info ^(.+\.php)(.*)$;
>         fastcgi_pass   127.0.0.1:9000;
>         fastcgi_index  index.php;
>         fastcgi_param  SCRIPT_FILENAME 
> /var/www$fastcgi_script_name;
>         include fastcgi_params;
>         fastcgi_param  QUERY_STRING    
> $query_string;
>         fastcgi_param  REQUEST_METHOD  
> $request_method;
>         fastcgi_param  CONTENT_TYPE    
> $content_type;
>         fastcgi_param  CONTENT_LENGTH  
> $content_length;
>         fastcgi_intercept_errors        on;
>         fastcgi_ignore_client_abort     off;
>         fastcgi_connect_timeout 60;
>         fastcgi_send_timeout 180;
>         fastcgi_read_timeout 180;
>         fastcgi_buffer_size 128k;
>         fastcgi_buffers 4 256k;
>         fastcgi_busy_buffers_size 256k;
>         fastcgi_temp_file_write_size 256k;
>     }
> 
> ## Disable viewing .htaccess & .htpassword
>     location ~ /\.ht {
>         deny  all;
>     }
> }
> upstream backend {
>         server 127.0.0.1:9000;
> }
> 
> Thanks

You can either use a php-based web interface for collectd like
php-collection or Collectd Graph Panel or if you need the ability to
serve .cgi and .pl files (like for awstats) you'll have to install
another backend daemon.

You can use a light web server or I'd recommend fcgiwrap.  A couple ppas
have Lucid backports of the Ubuntu fcgiwrap package, (e.g.
https://launchpad.net/~wwu-numerik/+archive/lucid).

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




More information about the nginx mailing list