【发布时间】:2019-02-14 06:58:51
【问题描述】:
我有一个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;
}
}
【问题讨论】:
-
您的问题特别是如何提供位于根目录中的文件?否则检查文件下载的文档:laravel.com/docs/5.7/responses#file-downloads
-
这是一种通过 nginx 而不是 Laravel 的方法吗?
标签: php laravel csv ubuntu nginx