📝 阿里云OSS挂载

← 返回笔记列表

阿里云OSS挂载

2026年03月24日 18:27

OSS地址和access信息

oss-test.oss-cn-shanghai-internal.aliyuncs.com LTAI4GBMp:dPuFVmBNMSV24g

通过SSH登录vps后下载安装包

wget http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/attach/32196/cn_zh/1527232195135/ossfs_1.80.5_centos7.0_x86_64.rpm

运行安装包

yum localinstall ossfs_1.80.5_centos7.0_x86_64.rpm -y

写入需要挂载的OSS配置信息

bucket名称Access Key ID 和 Access Key Secret等信息格式如下:

echo oss-test:LTAI4GBMp:dPuFVmBNMSV24g > /etc/passwd-ossfs
chmod 640 /etc/passwd-ossfs

挂载文件夹

ossfs BucketName mountfolder -o url=Endpoint

mkdir /opt/files
ossfs oss-test /opt/files -ourl=oss-cn-shanghai-internal.aliyuncs.com -o allow_other

取消挂载

umount /opt/files
fusermount -u /opt/files

开机自动挂载

vim /etc/init.d/ossfs

录入以下内容

ossfs oss-test /opt/files -ourl=oss-cn-shanghai-internal.aliyuncs.com -o allow_other

MAPP配置下载地址

vim /etc/nginx/nginx.conf
#配置files请求
location /files/ {
    root /opt/;
}

#配置防盗链
error_page  403              /403.html;
location /files/ {
    valid_referers *.saxxx.cn *.cxxx.com;
    if ($invalid_referer) {
        return 403;
    }
    proxy_set_header X-Forwarded-For '';
    proxy_pass mapp-uat.oss-cn-shanghai-internal.aliyuncs.com;
}

加载配置文件

nginx -s reload
返回顶部 ← 返回笔记列表