NGINX 下载文本文件而不是显示它

NGINX 下载文本文件而不是显示它

我已经安装了 Nginx,并且 nginx.conf 如下:

user              nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log;

pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /vagrant/access.log  main;

    sendfile        on;

    keepalive_timeout  65;

    include /etc/nginx/conf.d/*.conf;
}

每次我尝试任何文本文件的 URL(不是 PHP,它运行良好)时,浏览器都会要求下载它。

禁用等常见措施default-type octet/stream失败。

这是我的服务器块

server {
    listen       80;
    server_name  _;

    rewrite_log on;

    root   /var/www/planner.dev/src/public;
    #root   /usr/share/nginx/html/helloworld/public;
    index  index.php index.html index.htm;
    error_log /vagrant/default_server_error.log;

    try_files $uri $uri/ @rewrite;

    location @rewrite {
        rewrite ^/(.*)$ /index.php?_url=/$1;
    }

    location ~ \.php {
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_index   /index.php;

        include        fastcgi_params;
        fastcgi_split_path_info       ^(.+\.php)(/.+)$;
        fastcgi_param PATH_INFO       $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~ /\.ht {
        deny  all;
    }
}

相关内容