linux curl t上传文件,curl 命令行上传文件

现在nginx大行其道,一般在机器上装个nginx 简答配置下就可以做upload用了。主要需求是开发那边需要运维这边投递一些app_log和一些history log。下面讲解下直接用curl命令上传。

第一种:

server端有现成的ftpserver:

上传的option是 -T

比如我们向ftp传一个文件: curl -T localfile -u name:passwd ftp://upload_site:port/path/

curl -T hadoop_oom.log -u user:1234567 ftp://1.1.1.1/

第二种:

nginx上传: (需要加上--with-http_dav_module模块 )

./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_dav_module

make && make install

要创建上传的临时目录

mkdir -p /dev/shm/client_body_temp

nginx http段加入:

client_body_temp_path /dev/shm/client_body_temp 1 2;

client_max_body_size 1024m; #这个根据实际的情况,如有大文件upload需要加大,不然nginx抛413 error

然后:

server

{

listen 80;

server_name 1.1.1.1;

index index.html index.htm index.php;

root html;

autoindex on;

dav_methods PUT; #这个是重点默认不允许PUT

测试:

curl -T hadoop_oom.log

安全注意事项:

一般需要单独location一个目录单独做upload用。或者这个nginx只做upload上传单一用途。

然后就是nginx allow了,一般机房都是内网打通的,只允许idc内网才能PUT。不然就能任意PUT到你的upload机器了。

这样写脚本调用上传是不是很方便呢,哈哈。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值