我的网站下载.sh页面而不是显示它们

时间:2015-04-21 08:54:08

标签: nginx

当我点击此链接时,例如:http://debian.local/cgi-bin/hobbitcolumn.sh?bbgen下载.sh文件而不是显示它。

我试图将fastcgi_参数放在location ^~ /hobbit中,但仍无效。

你能帮帮我吗? 感谢

这是我的sites-available / debian.local.conf:

# /etc/nginx/sites-available/debian.local.conf
# HTTP server
server {
    listen   80; ## listen for ipv4; this line is default and implied
    #listen   [::]:80 default_server ipv6only=on; ## listen for ipv6

    # Make site accessible from http://localhost/
    server_name debian.local localhost ;
    # On redirige toutes les requêtes vers HTTPS
    #rewrite ^ https://$server_name$request_uri? permanent;

location ^~ /glpi {
  root /home/cedric/web;
  index index.php;

        location ~ /glpi(/.*\.php) {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass    unix:/var/run/php5-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_index index.php;
        }
}

location ^~ /hobbit {
                alias /usr/lib/hobbit/server/www/ ;
                index index.html ;

        }
location /cgi-bin/ {
                alias /usr/lib/hobbit/cgi-bin/;


}

location /cgi-secure/ {

                alias /usr/lib/hobbit/cgi-secure/ ;
}

}
server {
    listen 443 ssl;
    server_name debian.local localhost ;

    root html;
    index index.html index.htm;

    # Use a self-signed certificate to ensure
    # secure connexion to phpmyadmin
    ssl_certificate debian.local.crt;
    ssl_certificate_key debian.local.key;

    ssl_session_timeout 5m;

    # Access only latest browsers
    ssl_protocols TLSv1.2;
    ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
    ssl_prefer_server_ciphers on;

    location / {
        try_files $uri $uri/ =404;
    }

location /zabbix {
        if ($scheme ~ ^http:){
            rewrite ^(.*)$  https://$host$1 permanent;
        }
        alias                   /usr/share/zabbix;
        index                   index.php;
        error_page              403 404 502 503 504  /zabbix/index.php;

        location ~ \.php$ {
                if (!-f $request_filename) { return 404; }
                expires                 epoch;
                include                 /etc/nginx/fastcgi_params;
                fastcgi_index   index.php;
                fastcgi_pass    unix:/var/run/php5-fpm.sock;
    }

        location ~ \.(jpg|jpeg|gif|png|ico)$ {
                access_log      off;
                expires         33d;
        }

}

 location /phpmyadmin {
           root /usr/share/;
           index index.php index.html index.htm;

           location ~ ^/phpmyadmin/(.+\.php)$ {
                try_files $uri =404;
                root /usr/share/;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include /etc/nginx/fastcgi_params;
           }
           location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                   root /usr/share/;
           }
    }
    location /phpMyAdmin {
           rewrite ^/* /phpmyadmin last;
    }

    ## Xcache admin pages
    location /xcache {
        alias /usr/share/xcache/;
        try_files $uri $uri/ /index.php;

        location ~ ^/xcache/(.+\.php)$ {
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_param SCRIPT_FILENAME $request_filename;
            include fastcgi_params;
        }
    }
}

这是出现的而不是网页:

#!/bin/sh QS="${QUERY_STRING}" QUERY_STRING="db=columndoc.csv&key=${QS}" export QUERY_STRING . /usr/lib/hobbit/server/etc/hobbitcgi.cfg exec /usr/lib/hobbit/server/bin/bb-csvinfo.cgi $CGI_HOBBITCOLUMN_OPTS 

2 个答案:

答案 0 :(得分:0)

您应该在感兴趣的位置使用default_type指令,例如:

location /cgi-bin/ {
    alias /usr/lib/hobbit/cgi-bin/;
    default_type text/plain;
}

答案 1 :(得分:0)

我做到了。

这帮助了我:https://www.howtoforge.com/serving-cgi-scripts-with-nginx-on-debian-squeeze-ubuntu-11.04-p3

我安装了Fcgiwrap并编辑了sites-available/debian.local.conf,如下所示:

location /cgi-bin/ {
     # Disable gzip (it makes scripts feel slower since they have to complete
     # before getting gzipped)
     gzip off;
     # Set the root to /usr/lib (inside this location this means that we are
     # giving access to the files under /usr/lib/cgi-bin)
     alias  /usr/lib/hobbit/cgi-bin/;
     # Fastcgi socket
     fastcgi_pass  unix:/var/run/fcgiwrap.socket;
     # Fastcgi parameters, include the standard ones
     include /etc/nginx/fastcgi_params;
     # Adjust non standard parameters (SCRIPT_FILENAME)
     fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
   }

感谢。