# linux安装alist,反向代理教程-解决国内网络屏蔽问题|meiのblog

**URL:** <https://forum.rainyun.com/t/topic/5403>\
**Category:** 云服务器 RCS\
**Created:** [2023 年9 月 23 日 23:50 UTC](https://forum.rainyun.com/t/topic/5403 "2023-09-23T23:50:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

作者： ![mei](https://forum.rainyun.com/user_avatar/forum.rainyun.com/mei/32/8588_2.png) [@mei](https://forum.rainyun.com/u/mei)\
发布日期： [2023 年9 月 23 日 23:50 UTC](https://forum.rainyun.com/t/topic/5403/1 "2023-09-23T23:50:42Z")

</div>

[https://mmeiblog.cn/archives/alist](https://mmeiblog.cn/archives/alist)  
由于本文具有时效性，在此注明最后编辑日期，本文会不定期更新，但仅限我的blog，其它地方太麻烦了。 **最后编辑于：** 2023-9-23

关于alist资源国内加速:只是将脚本及安装文件放在了国内存储并修改了脚本，但仍需要我手动更新，在此注明最后一次更新时存储的alist版本:v3.28.0

此方法可有效解决国内网络屏蔽

# **安装**

如果你使用面板安装，先在面板创建一个网站，然后 cd 切换到网站目录

(仅适用于linux arm64/amd64平台)

```auto

# 我把脚本复制了一份，一样可以用还更快

curl -fsSL "https://cn-sy1.s3.rainyun.cn/static/alist/v3.sh" | bash -s install

# 官方命令(有可能无法访问)

curl -fsSL "https://alist.nn.ci/v3.sh" | bash -s install

```

更新

```auto

# 我改的脚本

curl -fsSL "https://cn-sy1.s3.rainyun.cn/static/alist/v3.sh" | bash -s update

# 官方命令

curl -fsSL "https://alist.nn.ci/v3.sh" | bash -s update

```

卸载

```auto

# 我改的脚本

curl -fsSL "https://cn-sy1.s3.rainyun.cn/static/alist/v3.sh" | bash -s uninstall

# 官方命令

curl -fsSL "https://alist.nn.ci/v3.sh" | bash -s uninstall

```

默认安装至opt/alist

自定义位置(将root替换为你想安装的位置)

```auto

# 我改的脚本

# 安装

curl -fsSL "https://cn-sy1.s3.rainyun.cn/static/alist/v3.sh" | bash -s install /root

# 更新

curl -fsSL "https://cn-sy1.s3.rainyun.cn/static/alist/v3.sh" | bash -s update /root

# 卸载

curl -fsSL "https://cn-sy1.s3.rainyun.cn/static/alist/v3.sh" | bash -s uninstall /root

# 官方命令

# 安装

curl -fsSL "https://alist.nn.ci/v3.sh" | bash -s install /root

# 更新

curl -fsSL "https://alist.nn.ci/v3.sh" | bash -s update /root

# 卸载

curl -fsSL "https://alist.nn.ci/v3.sh" | bash -s uninstall /root

```

- 启动: `systemctl start alist`

- 关闭: `systemctl stop alist`

- 状态: `systemctl status alist`

- 重启: `systemctl restart alist`

安装完成后访问

```auto

# 执行 ifconfig 来获取YOURIP

http://YOURIP:5244

```

## 获取密码

需要进入脚本安装AList的目录文件夹內执行如下命令

#### 低于v3.25.0版本

```bash

./alist admin

```

#### 高于v3.25.0版本

3.25.0以上版本将密码改成加密方式存储的hash值，无法直接反算出密码，如果忘记了密码只能通过重新 `随机生成` 或者 `手动设置`

```auto
# 随机生成一个密码./alist admin random# 手动设置一个密码,`NEW_PASSWORD`是指你需要设置的密码./alist admin set NEW_PASSWORD

```

# 反向代理

反向代理可以将5244端口监听至80/443端口，以此来部署SSL证书和不带端口访问。

## 本地代理

## 宝塔面板

[宝塔](https://www.bt.cn/?invite_code=M192aGJreGU=)

**如果您一开始就使用面板安装，请跳过第一步。**

1. 在宝塔的网站界面点击"添加站点"将php版本设置为纯静态,并将example.com替换为你的自定义域名  
 ![1](https://forum.rainyun.com/uploads/default/original/2X/9/94a1cc667b0701659c466ace2109ea0c0cbb034b.png)

**2. 点击设置-配置文件，删除图中框起来的几行，记得点保存**

 ![2](https://forum.rainyun.com/uploads/default/original/2X/d/d4a5d7537205ed8f5c8c2e2dadde1ddcfe0b6539.png)  
 ![3](https://forum.rainyun.com/uploads/default/original/2X/0/02fb48bf7df088777d24501dfb976ccb8f35c20c.png)  
3.接着在配置文件中随便找个地方粘贴以下配置： **（记得点保存）**  
 ![4](https://forum.rainyun.com/uploads/default/original/2X/1/197082e3848be18561595395d8286f3bc6838320.png)

```auto
location / {

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-Forwarded-Proto $scheme;

proxy_set_header Host $http_host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header Range $http_range;

proxy_set_header If-Range $http_if_range;

proxy_redirect off;

proxy_pass http://127.0.0.1:5244;

# the max size of file to upload

client_max_body_size 20000m;

}

```

4.添加A记录到你反向代理服务器的ip地址，使用内网穿透就A解析到内网穿透服务器ip或CNAME到内网穿透服务器域名

#### **部署SSL**

宝塔有一键部署，申请之后记得点保存，也可以使用阿里云或腾讯云的免费证书，用着更舒服

 ![5](https://forum.rainyun.com/uploads/default/original/2X/1/1c5e744122ac3b3912e2ab12bc8da2e8d1e32bd2.png)  
**1panel面板**  
1.点击网站–创建网站–反向代理，在代理地址处填写127.0.0.1，主域名替换为你的自定义域名  
 ![6](https://forum.rainyun.com/uploads/default/original/2X/9/9356d0f6125f33fa8d980f631f59c7dadd1a43c3.png)

2.在反向代理网站点击配置–配置文件，在如图位置粘贴以下配置，注意不要放在最后面的那个右花括号后面

 ![7](https://forum.rainyun.com/uploads/default/original/2X/5/51ba426c0868ab19b682e0a0373aca79c72b1f62.png)

```auto

location / {

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-Forwarded-Proto $scheme;

proxy_set_header Host $http_host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header Range $http_range;

proxy_set_header If-Range $http_if_range;

proxy_redirect off;

proxy_pass http://127.0.0.1:5244;

# the max size of file to upload

client_max_body_size 20000m;

}

```

#### **部署SSL**

先在证书页面申请证书，然后如图操作

 ![8](https://forum.rainyun.com/uploads/default/original/2X/c/c43c8b27154b1a1d47aa928faa8dda705b378f76.png)

#### **异地代理**

只需要把上文需要添加添加的配置文件改为以下配置即可，把第9行的YOURIP改成你alist服务器的公网ip地址1panel记得把代理地址也改成你服务器的公网ip地址。

```auto

# 把第9行的YOURIP改成你alist服务器的公网ip地址

location / {

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-Forwarded-Proto $scheme;

proxy_set_header Host $http_host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header Range $http_range;

proxy_set_header If-Range $http_if_range;

proxy_redirect off;

proxy_pass http://YOURIP:5244;

# the max size of file to upload

client_max_body_size 20000m;

}

```

# **服务器**

可以用雨云,自己当网盘用完全没问题 雨云可以填优惠码:cat

[雨云](https://www.rainyun.com/cat_)

如果使用内网穿透可以用樱花frp，界面好看免费额度还很多。

[樱花frp](https://www.natfrp.com/)

---

<div class="post-metadata">

作者： ![mei](https://forum.rainyun.com/user_avatar/forum.rainyun.com/mei/32/8588_2.png) [@mei](https://forum.rainyun.com/u/mei)\
发布日期： [2023 年11 月 5 日 01:11 UTC](https://forum.rainyun.com/t/topic/5403/2 "2023-11-05T01:11:42Z")

</div>

由于雨云ROS公测结束，复制的脚本已停止使用
