簡體   English   中英

如何配置Nginx返回CSV作為響應?

[英]How to configure Nginx to return a CSV as response?

我有一個test.csv文件位於在Ubuntu上運行的VM的根目錄下。 我在Laravel 4.2使用Nginx

在此處輸入圖片說明

  • 虛擬機IP: 1.1.1.1
  • 域名: www.site.com

如何通過我的網站www.site.com/csv公開訪問該CSV文件?

nginx的

server {

    listen 80 default_server;
    server_name site.com www.site.com;
    root /home/forge/john/public;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    index index.html index.htm index.php;
    charset utf-8;

    location /nginx_status {
        stub_status on;
        access_log off;
        allow 127.0.0.1;
        deny all;
    }

    location /resume {
        #auth_basic "Restricted";
        #auth_basic_user_file /home/forge/john/.htpasswd;
        try_files $uri $uri/ /index.php?$query_string;
    }

    location /getIconBasedOnDevicesName {
        proxy_pass http://localhost:3030;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/default-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }

}

如果文件位於/home/forge/john/public/test.csv ,則可以使用:

location = /csv {
    try_files /test.csv =404;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM