mirror of
https://github.com/XTLS/Xray-docs-next.git
synced 2026-09-22 22:38:05 +03:00
Tutorial: Remove outdated
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
你需要获取一台健康的、IP 没有被墙的 VPS,并在管理后台做下面这些基础准备:
|
||||
|
||||
1. 在 VPS 的后台安装 Debian 10 64bit 系统
|
||||
1. 在 VPS 的后台安装 Debian系统
|
||||
2. 小本本记下 VPS 的 IP 地址(本文会用 `"100.200.300.400"` 来表示)
|
||||
::: tip
|
||||
这是一个故意写错的非法 IP,请替换成你的真实 IP)
|
||||
@@ -17,7 +17,7 @@
|
||||
购买 VPS 是一个比较复杂的事情,建议先去学习一下相关知识,选择适合自己的经济能力和线路需求的即可。另外可以选择薅一些国际大厂的羊毛(比如甲骨文和谷歌提供的永久免费或限时免费的套餐)。总之,务必量力而行。
|
||||
|
||||
::: tip 说明
|
||||
关于选择 Debian 10 作为操作系统,这里稍微多说一句:不管你在网上听说了什么,不管哪个大神告诉你 XXX 版的 Linux 更好、XXX 版的 Linux 更牛,这些 Linux 的派系之争**跟现在的你半毛钱关系也没有**!使用 Debian 10 足以让你的 VPS 服务器在安全、稳健运行的同时得到足够的优化(如 cloud 专用内核、及时的 bbr 支持等)。等你对 Linux 熟悉之后,再回头去尝试其他的 Linux 发行版也不迟。
|
||||
关于选择 Debian 作为操作系统,这里稍微多说一句:不管你在网上听说了什么,不管哪个大神告诉你 XXX 版的 Linux 更好、XXX 版的 Linux 更牛,这些 Linux 的派系之争**跟现在的你半毛钱关系也没有**!使用最新的 Debian 稳定版足以让你的 VPS 服务器在安全、稳健运行的同时得到足够的优化(如 cloud 专用内核、及时的 bbr 支持等)。等你对 Linux 熟悉之后,再回头去尝试其他的 Linux 发行版也不迟。
|
||||
:::
|
||||
|
||||
## 2.2 获取一个心仪的域名
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
1. 小小白白 Linux 基础命令:
|
||||
| 编号 | 命令名称 | 命令说明 |
|
||||
|:--:|:--:|:--:|
|
||||
| `cmd-16` | `touch` | 建立空白文件 |
|
||||
| `cmd-15` | `touch` | 建立空白文件 |
|
||||
|
||||
2. 在`vpsadmin`的文件夹内建立一个【日志专用文件夹】
|
||||
|
||||
@@ -318,15 +318,12 @@ sudo systemctl enable xray
|
||||
|
||||
一句话:**不是!不要用这些!这些都为了吸引眼球乱起的名字!**
|
||||
|
||||
`BBR` 的更新和发布,都是跟随 Linux 的内核(`Kernel`)进行的。换言之,只要你用的是比较新的内核,就自然会使用到新版`BBR`。
|
||||
BBR 是内核自带跟随内核发布并更新的,而这些名字看起来很酷炫的东西,说白了就是作者自行调整 `BBR` 参数以及使用这些参数构建出的内核,这些脚本也仅仅就是下载安装这些魔改内核。
|
||||
|
||||
而这些名字看起来很酷炫的东西,说白了就是仍未正式发布的、尚在测试阶段的内核及其对应的`BBR`版本。这些脚本也仅仅就是通过下载预览版的内核(甚至第三方魔改内核)来率先开启而已。
|
||||
|
||||
内核的稳定是一台服务器稳定运行的基石。**【BBR 测试版带来的细微性能差异绝对不值得更换不稳定的内核。】** 请选择你所在的 Linux 发行版所支持的最新内核,这样可以最大限度的保持服务器的长期稳定和兼容。
|
||||
内核的稳定是一台服务器稳定运行的基石。**【BBR 魔改版带来的细微性能差异绝对不值得更换不稳定的内核。】** 请选择你所在的 Linux 发行版所支持的最新内核,这样可以最大限度的保持服务器的长期稳定和兼容。
|
||||
|
||||
::: warning
|
||||
所谓魔改`bbr`的【领先】是有非常强的时效性的。比如很多 `bbrplus` 脚本,因为几年来都没有更新,到现在还会把你的内核换成 `4.19`,要知道现在稳定如 Debian 已经是 `5.9`
|
||||
的时代了,那么这个脚本放在 2018 年 1 月也许领先了一点,到 2018 年 10 月 4.19 正发布时就已经失去了意义,放在现在甚至可以说是完完全全的【降级】和【劣化】
|
||||
所谓魔改`bbr`的【领先】是有非常强的时效性的。比如很多 `bbrplus` 脚本,因为几年来都没有更新,到现在还会把你的内核换成很老的版本,导致你的系统失去安全性甚至无法启动。
|
||||
:::
|
||||
|
||||
4. `fq`, `fq_codel`, `fq_pie`, `cake`和其他算法哪个好?
|
||||
@@ -346,101 +343,53 @@ sudo systemctl enable xray
|
||||
如果你的线路真的丢包率奇高,真正靠谱的解决方案是【换线路】。
|
||||
:::
|
||||
|
||||
6. 啰嗦了这么多,就是因为围绕 `BBR` 忽悠小白的错误概念和坑人脚本实在是太多了。我希望你们现在对 `BBR` 有了相对清晰的理解。接下来,我们就动手安装最新的 Debian 内核并开启`BBR` 吧!(真的很简单)
|
||||
6. 啰嗦了这么多,就是因为围绕 `BBR` 忽悠小白的错误概念和坑人脚本实在是太多了。我希望你们现在对 `BBR` 有了相对清晰的理解。接下来,我们就动手开启`BBR` 吧!
|
||||
|
||||
7. 给 Debian 10 添加官方 `backports` 源,获取更新的软件库
|
||||
7. 添加参数配置文件并指定开启 `BBR`
|
||||
|
||||
```shell
|
||||
sudo nano /etc/apt/sources.list
|
||||
sudo nano /etc/sysctl.d/99-bbr.conf
|
||||
```
|
||||
|
||||
::: warning 说明
|
||||
本文以 Debian 10 为例,所以使用 `/etc/apt/sources.list` 仍无问题,但如果你并不是根据本文从头开始,或者使用了其他 Linux
|
||||
发行版,那么建议你建立 `/etc/apt/sources.list.d/` 文件夹,并在这个文件夹内建立自己的配置文件,形如 `/etc/apt/sources.list.d/vpsadmin.list`
|
||||
,以此保证兼容性,也可避免默认文件在不可预见的情况下被覆盖而导致配置丢失。
|
||||
:::
|
||||
|
||||
8. 然后把下面这一条加在最后,并保存退出。
|
||||
|
||||
```
|
||||
deb http://archive.debian.org/debian buster-backports main
|
||||
```
|
||||
|
||||
9. 刷新软件库并查询 Debian 官方的最新版内核并安装。请务必安装你的 VPS 对应的版本(本文以比较常见的【amd64】为例)。
|
||||
|
||||
```shell
|
||||
sudo apt update && sudo apt -t buster-backports install linux-image-amd64
|
||||
```
|
||||
|
||||
::: warning 注意
|
||||
|
||||
如果你的 VPS 支持,可以尝试【云服务器专用内核】`linux-image-cloud-amd64`,优点就是精简、资源占用低,缺点嘛是有同学反馈不支持的系统强行安装会导致无法开机(Kernel 无法识别)。
|
||||
|
||||
为了避免无法识别的悲剧,请确保:
|
||||
|
||||
- 尝试前做一个系统快照,或者
|
||||
- 你有 `vnc` 可以救场(并且你知道怎么用)
|
||||
|
||||
:::
|
||||
|
||||
10. 修改 `kernel` 参数配置文件 `sysctl.conf` 并指定开启 `BBR`
|
||||
|
||||
```shell
|
||||
sudo nano /etc/sysctl.conf
|
||||
```
|
||||
|
||||
::: warning 说明
|
||||
本文以 Debian 10 为例,所以使用 `/etc/sysctl.conf` 仍无问题,但如果你并不是跟着本文从头开始,或者使用了其他 Linux 发行版,那么建议你建立 `/etc/sysctl.d/`
|
||||
文件夹,并在这个文件夹内建立自己的配置文件,形如 `/etc/sysctl.d/vpsadmin.conf`,以此保证兼容性,因为部分发行版在 `systemd`
|
||||
207 版本之后便不再从 `/etc/sysctl.conf` 读取参数。使用自定义配置文件也可避免默认文件在不可预见的情况下被覆盖而导致配置丢失。
|
||||
:::
|
||||
|
||||
11. 把下面的内容添加进去
|
||||
8. 把下面的内容添加进去
|
||||
|
||||
```
|
||||
net.core.default_qdisc=fq
|
||||
net.ipv4.tcp_congestion_control=bbr
|
||||
```
|
||||
|
||||
12. 重启 VPS、使内核更新和`BBR`设置都生效
|
||||
9. 读取配置,使 `BBR` 设置生效
|
||||
|
||||
```shell
|
||||
sudo reboot
|
||||
sudo sysctl --system
|
||||
```
|
||||
|
||||
13. 完整流程演示如下:
|
||||
|
||||
::: tip 啰嗦君
|
||||
因为我做展示的 VPS 支持云服务器专用内核,所以动图中我用了 `linux-image-cloud-amd64`
|
||||
。如果你不确定你的 VPS 是否支持,那请务必按照第 3 步的命令,使用常规内核 `linux-image-amd64`。
|
||||
:::
|
||||
|
||||

|
||||
|
||||
14. 确认`BBR`开启
|
||||
10. 确认`BBR`开启
|
||||
|
||||
如果你想确认 `BBR` 是否正确开启,可以使用下面的命令:
|
||||
|
||||
```shell
|
||||
lsmod | grep bbr
|
||||
sysctl net.ipv4.tcp_congestion_control
|
||||
```
|
||||
|
||||
此时应该返回这样的结果:
|
||||
|
||||
```
|
||||
tcp_bbr
|
||||
net.ipv4.tcp_congestion_control = bbr
|
||||
```
|
||||
|
||||
如果你在疑惑这个 `ipv4`,无需在意,只是历史命名遗留,实际上对 `ipv6` 也是生效的。
|
||||
|
||||
如果你想确认 `fq` 算法是否正确开启,可以使用下面的命令:
|
||||
|
||||
```shell
|
||||
lsmod | grep fq
|
||||
sysctl net.core.default_qdisc
|
||||
```
|
||||
|
||||
此时应该返回这样的结果:
|
||||
|
||||
```
|
||||
sch_fq
|
||||
net.core.default_qdisc = fq
|
||||
```
|
||||
|
||||
## 7.8 服务器优化之二:开启 HTTP 自动跳转 HTTPS
|
||||
|
||||
@@ -18,22 +18,17 @@
|
||||
| `cmd-12` | `wget` | 访问(或下载)某个网页文件 | [《证书管理篇》](./ch06-certificates.md) |
|
||||
| `cmd-13` | `acme.sh` | acme.sh 证书管理相关的命令 | [《证书管理篇》](./ch06-certificates.md) |
|
||||
| `cmd-14` | `rm` | 删除命令 | [《Xray 服务器篇》](./ch07-xray-server.md) |
|
||||
| `cmd-15` | `crontab -e` | 编辑当前用户的定时任务 | [《Xray 服务器篇》](./ch07-xray-server.md) |
|
||||
| `cmd-16` | `touch` | 建立空白文件 | [《Xray 服务器篇》](./ch07-xray-server.md) |
|
||||
| `cmd-17` | `systemctl` | `systemd`基本服务管理命令 | [《Xray 服务器篇》](./ch07-xray-server.md) |
|
||||
| `cmd-18` | `reboot` | 重启 Linux 系统 | [《Xray 服务器篇》](./ch07-xray-server.md) |
|
||||
| `cmd-15` | `touch` | 建立空白文件 | [《Xray 服务器篇》](./ch07-xray-server.md) |
|
||||
| `cmd-16` | `systemctl` | `systemd`基本服务管理命令 | [《Xray 服务器篇》](./ch07-xray-server.md) |
|
||||
| `cmd-17` | `reboot` | 重启 Linux 系统 | [《Xray 服务器篇》](./ch07-xray-server.md) |
|
||||
|
||||
## 2. 小小白白 Linux 重要配置文件索引
|
||||
|
||||
| 编号 | 配置文件位置 | 文件说明 | 出现篇章 |
|
||||
| :-------: | :-------------------------------------- | :----------------------------- | :----------------------------------------: |
|
||||
| `conf-01` | `/etc/ssh/sshd_config` | SSH 远程登录程序设置 | [《远程登录篇》](./ch03-ssh.md) |
|
||||
| `conf-02` | `/etc/nginx/nginx.conf` | Nginx 程序设置 | [《网站建设篇》](./ch05-webpage.md) |
|
||||
| `conf-03` | `/etc/apt/sources.list` | apt 软件源列表 | [《Xray 服务器篇》](./ch07-xray-server.md) |
|
||||
| `conf-04` | `/etc/apt/sources.list.d/vpsadmin.list` | 用户自定义软件源列表列表 | [《Xray 服务器篇》](./ch07-xray-server.md) |
|
||||
| `conf-05` | `crontab -e` | 当前用户的定时任务 | [《Xray 服务器篇》](./ch07-xray-server.md) |
|
||||
| `conf-06` | `/etc/sysctl.conf` | 手动设置 kernel 参数 | [《Xray 服务器篇》](./ch07-xray-server.md) |
|
||||
| `conf-07` | `/etc/sysctl.d/vpsadmin.conf` | 用户自定义 kernel 参数配置文件 | [《Xray 服务器篇》](./ch07-xray-server.md) |
|
||||
| 编号 | 配置文件位置 | 文件说明 | 出现篇章 |
|
||||
| :-------: | :-------------------------- | :------------------------- | :----------------------------------------: |
|
||||
| `conf-01` | `/etc/ssh/sshd_config` | SSH 远程登录程序设置 | [《远程登录篇》](./ch03-ssh.md) |
|
||||
| `conf-02` | `/etc/nginx/nginx.conf` | Nginx 程序设置 | [《网站建设篇》](./ch05-webpage.md) |
|
||||
| `conf-03` | `/etc/sysctl.d/99-bbr.conf` | 自定义 kernel 参数配置文件 | [《Xray 服务器篇》](./ch07-xray-server.md) |
|
||||
|
||||
## 3. 小小白白 Xray 重要文件索引
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ This chapter is somewhat special because it involves monetary transactions. Base
|
||||
|
||||
You need to obtain a healthy VPS whose IP is not blocked, and complete the following basic preparations in the management panel:
|
||||
|
||||
1. Install the **Debian 10 64bit** system in the VPS management panel.
|
||||
1. Install the **Debian** system in the VPS management panel.
|
||||
2. Make a note of the VPS IP address (this article will use `"100.200.300.400"` to represent it).
|
||||
::: tip
|
||||
This is a deliberately written illegal IP; please replace it with your real IP.
|
||||
@@ -17,7 +17,7 @@ You need to obtain a healthy VPS whose IP is not blocked, and complete the follo
|
||||
Purchasing a VPS is a relatively complex matter. It is recommended to learn some relevant knowledge first and choose one that fits your financial ability and line quality needs. Additionally, you can choose to take advantage of free offers from major international tech giants (such as the permanent free or limited-time free tiers provided by Oracle and Google). In short, please act according to your means.
|
||||
|
||||
::: tip Note
|
||||
Regarding the choice of Debian 10 as the operating system, let me add a few words here: No matter what you hear online, no matter which "guru" tells you that XXX version of Linux is better or XXX version of Linux is cooler, these Linux distro wars **have absolutely nothing to do with you right now**! Using Debian 10 is sufficient to allow your VPS server to run securely and stably while receiving enough optimization (such as cloud-specific kernels, timely BBR support, etc.). Once you are familiar with Linux, it won't be too late to look back and try other Linux distributions.
|
||||
Regarding the choice of Debian as the operating system, let me add a few words here: No matter what you hear online, no matter which "guru" tells you that XXX version of Linux is better or XXX version of Linux is cooler, these Linux distro wars **have absolutely nothing to do with you right now**! Using the latest Debian stable release is sufficient to allow your VPS server to run securely and stably while receiving enough optimization (such as cloud-specific kernels, timely BBR support, etc.). Once you are familiar with Linux, it won't be too late to look back and try other Linux distributions.
|
||||
:::
|
||||
|
||||
## 2.2 Obtain a Desired Domain Name
|
||||
|
||||
@@ -102,7 +102,7 @@ First, various configurations can refer to the [official VLESS configuration exa
|
||||
|
||||
| Number | Command Name | Command Description |
|
||||
| :------: | :----------: | :-----------------: |
|
||||
| `cmd-16` | `touch` | Create a blank file |
|
||||
| `cmd-15` | `touch` | Create a blank file |
|
||||
|
||||
2. Create a [Log Dedicated Folder] inside the `vpsadmin` folder.
|
||||
|
||||
@@ -309,14 +309,12 @@ So far, we have used `systemctl` related commands like `start`, `status`, `reloa
|
||||
|
||||
In one word: **No! Don't use these! These are names made up just to attract attention!**
|
||||
|
||||
The update and release of `BBR` follow the Linux kernel (`Kernel`). In other words, as long as you use a relatively new kernel, you will naturally use the new version of `BBR`.
|
||||
Those things with cool-sounding names are essentially kernels that the authors have rebuilt with their own tweaked `BBR` parameters. These scripts merely download and install those modified kernels for you.
|
||||
|
||||
And those things with cool names are essentially unreleased kernels still in the testing phase and their corresponding `BBR` versions. These scripts merely enable them by downloading preview kernels (or even third-party modified kernels).
|
||||
|
||||
Kernel stability is the cornerstone of a stable server operation. **[The subtle performance difference brought by the BBR beta version is absolutely not worth swapping for an unstable kernel.]** Please choose the latest kernel supported by your Linux distribution, which maximizes the long-term stability and compatibility of the server.
|
||||
Kernel stability is the cornerstone of a stable server operation. **[The subtle performance difference brought by modified BBR versions is absolutely not worth swapping for an unstable kernel.]** Please choose the latest kernel supported by your Linux distribution, which maximizes the long-term stability and compatibility of the server.
|
||||
|
||||
::: warning
|
||||
The so-called "lead" of modified `bbr` has a very strong timeliness. For example, many `bbrplus` scripts have not been updated for several years, and even now they will replace your kernel with `4.19`. You should know that stable distributions like Debian are already in the `5.9` era. So maybe this script was a little ahead in January 2018, but by October 2018 when 4.19 was officially released, it had lost its meaning. Putting it in use now can even be considered a complete [Downgrade] and [Degradation].
|
||||
The so-called "lead" of modified `bbr` has a very strong timeliness. For example, many `bbrplus` scripts have not been updated for years, and to this day will still downgrade your kernel to a very old version, leaving your system insecure or even unbootable.
|
||||
:::
|
||||
|
||||
4. Which algorithm is better: `fq`, `fq_codel`, `fq_pie`, `cake` or others?
|
||||
@@ -335,93 +333,53 @@ So far, we have used `systemctl` related commands like `start`, `status`, `reloa
|
||||
If your line really has a ridiculously high packet loss rate, the truly reliable solution is to [Change the Line].
|
||||
:::
|
||||
|
||||
6. I've been rambling so much because there are too many misconceptions and pitfall scripts fooling newbies surrounding `BBR`. I hope you now have a relatively clear understanding of `BBR`. Next, let's install the latest Debian kernel and enable `BBR`! (It's really simple)
|
||||
6. I've been rambling so much because there are too many misconceptions and pitfall scripts fooling newbies surrounding `BBR`. I hope you now have a relatively clear understanding of `BBR`. Next, let's enable `BBR`!
|
||||
|
||||
7. Add the official `backports` source to Debian 10 to get updated software libraries.
|
||||
7. Create a parameter configuration file and enable `BBR`.
|
||||
|
||||
```shell
|
||||
sudo nano /etc/apt/sources.list
|
||||
sudo nano /etc/sysctl.d/99-bbr.conf
|
||||
```
|
||||
|
||||
::: warning Note
|
||||
This article takes Debian 10 as an example, so using `/etc/apt/sources.list` is fine. However, if you are not starting from scratch following this article, or are using another Linux distribution, I suggest you create a `/etc/apt/sources.list.d/` folder and create your own configuration file inside this folder, like `/etc/apt/sources.list.d/vpsadmin.list`. This ensures compatibility and avoids configuration loss caused by default files being overwritten in unforeseen circumstances.
|
||||
:::
|
||||
|
||||
8. Then add the following line at the end, save, and exit.
|
||||
|
||||
```
|
||||
deb [http://archive.debian.org/debian](http://archive.debian.org/debian) buster-backports main
|
||||
```
|
||||
|
||||
9. Refresh the software library, query the latest official Debian kernel, and install it. Please be sure to install the version corresponding to your VPS (this article uses the common [amd64] as an example).
|
||||
|
||||
```shell
|
||||
sudo apt update && sudo apt -t buster-backports install linux-image-amd64
|
||||
```
|
||||
|
||||
::: warning Attention
|
||||
If your VPS supports it, you can try the [Cloud Server Dedicated Kernel] `linux-image-cloud-amd64`. The advantage is that it is streamlined and uses fewer resources. The downside is that some students reported that forcing installation on unsupported systems leads to boot failure (Kernel cannot be recognized).
|
||||
|
||||
To avoid the tragedy of being unable to recognize the kernel, please ensure:
|
||||
- Take a system snapshot before trying, or
|
||||
- You have `vnc` to save the situation (and you know how to use it)
|
||||
:::
|
||||
|
||||
10. Modify the `kernel` parameter configuration file `sysctl.conf` and specify enabling `BBR`.
|
||||
|
||||
```shell
|
||||
sudo nano /etc/sysctl.conf
|
||||
```
|
||||
|
||||
::: warning Note
|
||||
This article takes Debian 10 as an example, so using `/etc/sysctl.conf` is fine. However, if you are not starting from scratch following this article, or are using another Linux distribution, I suggest you create a `/etc/sysctl.d/` folder and create your own configuration file inside this folder, like `/etc/sysctl.d/vpsadmin.conf`. This ensures compatibility because some distributions no longer read parameters from `/etc/sysctl.conf` after `systemd` version 207. Using a custom configuration file also avoids configuration loss caused by default files being overwritten in unforeseen circumstances.
|
||||
:::
|
||||
|
||||
11. Add the following content into it:
|
||||
8. Add the following content into it:
|
||||
|
||||
```
|
||||
net.core.default_qdisc=fq
|
||||
net.ipv4.tcp_congestion_control=bbr
|
||||
```
|
||||
|
||||
12. Reboot the VPS to make the kernel update and `BBR` settings take effect.
|
||||
9. Reboot the VPS to make the `BBR` settings take effect.
|
||||
|
||||
```shell
|
||||
sudo reboot
|
||||
```
|
||||
|
||||
13. The complete process demonstration is as follows:
|
||||
|
||||
::: tip Mr. Verbose
|
||||
Because the VPS I used for the demonstration supports the cloud server dedicated kernel, I used `linux-image-cloud-amd64` in the GIF. If you are not sure if your VPS supports it, please be sure to follow the command in step 3 and use the regular kernel `linux-image-amd64`.
|
||||
:::
|
||||
|
||||

|
||||
|
||||
14. Confirm `BBR` is enabled
|
||||
10. Confirm `BBR` is enabled
|
||||
|
||||
If you want to confirm if `BBR` is enabled correctly, you can use the following command:
|
||||
|
||||
```shell
|
||||
lsmod | grep bbr
|
||||
sysctl net.ipv4.tcp_congestion_control
|
||||
```
|
||||
|
||||
It should return a result like this:
|
||||
|
||||
```
|
||||
tcp_bbr
|
||||
net.ipv4.tcp_congestion_control = bbr
|
||||
```
|
||||
|
||||
If you are wondering about the `ipv4` here, don't worry — it's just legacy naming, and the setting takes effect for IPv6 as well.
|
||||
|
||||
If you want to confirm if the `fq` algorithm is enabled correctly, you can use the following command:
|
||||
|
||||
```shell
|
||||
lsmod | grep fq
|
||||
sysctl net.core.default_qdisc
|
||||
```
|
||||
|
||||
It should return a result like this:
|
||||
|
||||
```
|
||||
sch_fq
|
||||
net.core.default_qdisc = fq
|
||||
```
|
||||
|
||||
## 7.8 Server Optimization 2: Enable Auto-Redirect from HTTP to HTTPS
|
||||
|
||||
@@ -18,22 +18,17 @@
|
||||
| `cmd-12` | `wget` | Access (or download) a web file | [[Chapter 6: Certificate Management]](./ch06-certificates.md) |
|
||||
| `cmd-13` | `acme.sh` | Commands related to acme.sh certificate management | [[Chapter 6: Certificate Management]](./ch06-certificates.md) |
|
||||
| `cmd-14` | `rm` | Remove (delete) command | [[Chapter 7: Xray Server]](./ch07-xray-server.md) |
|
||||
| `cmd-15` | `crontab -e` | Edit current user's scheduled tasks | [[Chapter 7: Xray Server]](./ch07-xray-server.md) |
|
||||
| `cmd-16` | `touch` | Create an empty file | [[Chapter 7: Xray Server]](./ch07-xray-server.md) |
|
||||
| `cmd-17` | `systemctl` | Basic `systemd` service management command | [[Chapter 7: Xray Server]](./ch07-xray-server.md) |
|
||||
| `cmd-18` | `reboot` | Reboot the Linux system | [[Chapter 7: Xray Server]](./ch07-xray-server.md) |
|
||||
| `cmd-15` | `touch` | Create an empty file | [[Chapter 7: Xray Server]](./ch07-xray-server.md) |
|
||||
| `cmd-16` | `systemctl` | Basic `systemd` service management command | [[Chapter 7: Xray Server]](./ch07-xray-server.md) |
|
||||
| `cmd-17` | `reboot` | Reboot the Linux system | [[Chapter 7: Xray Server]](./ch07-xray-server.md) |
|
||||
|
||||
## 2. Index of Important Linux Configuration Files for Beginners
|
||||
|
||||
| ID | Config File Location | File Description | Featured Chapter |
|
||||
| :-------: | :-------------------------------------- | :---------------------------------------- | :------------------------------------------------: |
|
||||
| `conf-01` | `/etc/ssh/sshd_config` | SSH remote login program settings | [[Chapter 3: Remote Login]](./ch03-ssh.md) |
|
||||
| `conf-02` | `/etc/nginx/nginx.conf` | Nginx program settings | [[Chapter 5: Website Building]](./ch05-webpage.md) |
|
||||
| `conf-03` | `/etc/apt/sources.list` | apt software source list | [[Chapter 7: Xray Server]](./ch07-xray-server.md) |
|
||||
| `conf-04` | `/etc/apt/sources.list.d/vpsadmin.list` | User-defined software source list | [[Chapter 7: Xray Server]](./ch07-xray-server.md) |
|
||||
| `conf-05` | `crontab -e` | Current user's scheduled tasks | [[Chapter 7: Xray Server]](./ch07-xray-server.md) |
|
||||
| `conf-06` | `/etc/sysctl.conf` | Manual kernel parameter settings | [[Chapter 7: Xray Server]](./ch07-xray-server.md) |
|
||||
| `conf-07` | `/etc/sysctl.d/vpsadmin.conf` | User-defined kernel parameter config file | [[Chapter 7: Xray Server]](./ch07-xray-server.md) |
|
||||
| ID | Config File Location | File Description | Featured Chapter |
|
||||
| :-------: | :-------------------------- | :---------------------------------- | :------------------------------------------------: |
|
||||
| `conf-01` | `/etc/ssh/sshd_config` | SSH remote login program settings | [[Chapter 3: Remote Login]](./ch03-ssh.md) |
|
||||
| `conf-02` | `/etc/nginx/nginx.conf` | Nginx program settings | [[Chapter 5: Website Building]](./ch05-webpage.md) |
|
||||
| `conf-03` | `/etc/sysctl.d/99-bbr.conf` | Custom kernel parameter config file | [[Chapter 7: Xray Server]](./ch07-xray-server.md) |
|
||||
|
||||
## 3. Index of Important Xray Files for Beginners
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
Вам нужно получить работающий VPS с не заблокированным IP-адресом и выполнить следующие базовые действия в панели управления:
|
||||
|
||||
1. Установить на VPS операционную систему Debian 10 64-bit.
|
||||
1. Установить на VPS операционную систему Debian.
|
||||
2. Записать IP-адрес VPS (в этой статье он будет обозначаться как `"100.200.300.400"`).
|
||||
::: tip
|
||||
Это **неверный** IP-адрес, используемый только в качестве примера. Не забудьте заменить его на свой реальный IP-адрес.
|
||||
@@ -17,7 +17,7 @@
|
||||
Выбор и покупка VPS — дело непростое. Рекомендуем сначала изучить этот вопрос и выбрать тариф, который соответствует вашим финансовым возможностям и требованиям к скорости и качеству связи. Также можно воспользоваться бесплатными (постоянными или временными) предложениями от крупных облачных провайдеров, таких как Oracle Cloud и Google Cloud. Главное — не влезайте в долги.
|
||||
|
||||
::: tip Пояснение
|
||||
Несколько слов о выборе Debian 10 в качестве операционной системы. Что бы вы ни слышали в интернете, какой бы дистрибутив Linux ни советовали вам гуру, все эти споры о том, какой Linux лучше, **не имеют к вам никакого отношения**! Debian 10 — это надёжная и стабильная операционная система, которая отлично подходит для работы VPN-сервера и достаточно оптимизирована (например, имеет специальное ядро для облачных сред и своевременную поддержку BBR). Когда вы освоитесь с Linux, можете попробовать и другие дистрибутивы.
|
||||
Несколько слов о выборе Debian в качестве операционной системы. Что бы вы ни слышали в интернете, какой бы дистрибутив Linux ни советовали вам гуру, все эти споры о том, какой Linux лучше, **не имеют к вам никакого отношения**! Последний стабильный выпуск Debian — это надёжная и стабильная операционная система, которая отлично подходит для работы VPN-сервера и достаточно оптимизирована (например, имеет специальное ядро для облачных сред и своевременную поддержку BBR). Когда вы освоитесь с Linux, можете попробовать и другие дистрибутивы.
|
||||
:::
|
||||
|
||||
## 2.2 Выбор доменного имени
|
||||
|
||||
@@ -102,7 +102,7 @@ Xray основан на проекте с открытым исходным к
|
||||
|
||||
| Номер | Команда | Описание |
|
||||
| :------: | :-----: | :--------------------- |
|
||||
| `cmd-16` | `touch` | Создание пустого файла |
|
||||
| `cmd-15` | `touch` | Создание пустого файла |
|
||||
|
||||
2. Создаём папку для логов в домашней директории пользователя `vpsadmin`:
|
||||
|
||||
@@ -310,14 +310,12 @@ Xray основан на проекте с открытым исходным к
|
||||
|
||||
Одним словом: **нет! Не используйте их! Все эти названия придуманы только для привлечения внимания!**
|
||||
|
||||
Обновления `BBR` выпускаются вместе с обновлениями ядра Linux (`Kernel`). Другими словами, если вы используете относительно новое ядро, то у вас уже будет установлена последняя версия `BBR`.
|
||||
На самом деле эти "крутые" версии — это просто ядра, которые авторы пересобрали со своими собственными изменёнными параметрами `BBR`. А упомянутые скрипты лишь скачивают и устанавливают эти модифицированные ядра.
|
||||
|
||||
А все эти скрипты с крутыми названиями просто скачивают и устанавливают предварительные версии ядра (или даже модифицированные сторонними разработчиками версии) с более новыми версиями `BBR`.
|
||||
|
||||
Стабильность ядра — это основа стабильной работы сервера. **Незначительное повышение производительности, которое могут дать тестовые версии `BBR`, не стоит того, чтобы рисковать стабильностью сервера.** Используйте последнюю версию ядра, которая поддерживается вашим дистрибутивом Linux. Это обеспечит максимальную стабильность и совместимость вашего сервера.
|
||||
Стабильность ядра — это основа стабильной работы сервера. **Незначительное повышение производительности, которое могут дать модифицированные версии `BBR`, не стоит того, чтобы рисковать стабильностью сервера.** Используйте последнюю версию ядра, которая поддерживается вашим дистрибутивом Linux. Это обеспечит максимальную стабильность и совместимость вашего сервера.
|
||||
|
||||
::: warning
|
||||
Так называемое "преимущество" модифицированных версий `bbr` **очень недолговечно**. Например, многие скрипты `bbrplus` до сих пор устанавливают ядро версии 4.19, поскольку не обновлялись уже несколько лет. А ведь на дворе уже эпоха Debian 11 с ядром 5.10! То есть, если в январе 2018 года этот скрипт, возможно, и давал какое-то преимущество, то уже к октябрю 2018 года, когда вышла стабильная версия ядра 4.19, он потерял всякий смысл. А сейчас его использование и вовсе можно назвать **даунгрейдом**.
|
||||
Так называемое "преимущество" модифицированных версий `bbr` **очень недолговечно**. Например, многие скрипты `bbrplus` не обновлялись уже несколько лет и до сих пор устанавливают на сервер очень старые версии ядра, что приводит к потере безопасности системы или даже к невозможности её загрузки.
|
||||
:::
|
||||
|
||||
4. Какой алгоритм управления очередями использовать: `fq`, `fq_codel`, `fq_pie`, `cake` или какой-то другой?
|
||||
@@ -336,94 +334,54 @@ Xray основан на проекте с открытым исходным к
|
||||
Если у вас действительно плохой канал с высокими потерями пакетов, то единственное правильное решение — **сменить провайдера**.
|
||||
:::
|
||||
|
||||
6. Я так подробно остановился на `BBR`, потому что вокруг него слишком много мифов и откровенной дезинформации, нацеленной на новичков. Надеюсь, теперь у вас есть чёткое представление о том, что такое `BBR` и как он работает. А теперь давайте установим последнюю версию ядра Debian и включим `BBR`! (Это действительно просто)
|
||||
1. Добавляем репозиторий `backports` в Debian 10, чтобы получить доступ к более новым версиям пакетов:
|
||||
6. Я так подробно остановился на `BBR`, потому что вокруг него слишком много мифов и откровенной дезинформации, нацеленной на новичков. Надеюсь, теперь у вас есть чёткое представление о том, что такое `BBR` и как он работает. А теперь давайте включим `BBR`!
|
||||
|
||||
```shell
|
||||
sudo nano /etc/apt/sources.list
|
||||
```
|
||||
7. Создаём файл с параметрами и включаем `BBR`:
|
||||
|
||||
::: warning
|
||||
В Debian 10 можно без проблем использовать файл `/etc/apt/sources.list`. Однако, если вы используете другой дистрибутив Linux или не устанавливали систему с нуля по этой инструкции, то рекомендуется создать папку `/etc/apt/sources.list.d/` и добавлять свои файлы конфигурации в неё, например, `/etc/apt/sources.list.d/vpsadmin.list`. Это обеспечит совместимость с другими дистрибутивами и предотвратит потерю настроек при случайном перезаписывании файла `/etc/apt/sources.list`.
|
||||
:::
|
||||
```shell
|
||||
sudo nano /etc/sysctl.d/99-bbr.conf
|
||||
```
|
||||
|
||||
2. Добавляем следующую строку в конец файла и сохраняем его:
|
||||
8. Добавляем в него следующие строки:
|
||||
|
||||
```
|
||||
deb http://archive.debian.org/debian buster-backports main
|
||||
```
|
||||
```
|
||||
net.core.default_qdisc=fq
|
||||
net.ipv4.tcp_congestion_control=bbr
|
||||
```
|
||||
|
||||
3. Обновляем список доступных пакетов, ищем последнюю версию ядра Debian и устанавливаем её. Устанавливайте версию ядра, которая подходит для вашей архитектуры (в данном руководстве мы используем `amd64`):
|
||||
9. Перезагружаем VPS, чтобы настройки `BBR` вступили в силу:
|
||||
|
||||
```shell
|
||||
sudo apt update && sudo apt -t buster-backports install linux-image-amd64
|
||||
```
|
||||
```shell
|
||||
sudo reboot
|
||||
```
|
||||
|
||||
::: warning
|
||||
Если ваш VPS поддерживает это, вы можете попробовать установить **специальное ядро для облачных серверов** `linux-image-cloud-amd64`. Его преимущества — это меньший размер и меньшее потребление ресурсов. Однако некоторые пользователи сталкивались с проблемами при установке этого ядра на неподдерживаемые системы, вплоть до невозможности загрузки (ядро не определялось).
|
||||
10. Проверяем, что `BBR` включён
|
||||
|
||||
Чтобы не попасть в такую ситуацию, перед установкой этого ядра:
|
||||
- создайте снапшот системы или
|
||||
- убедитесь, что у вас есть доступ к `vnc`-консоли (и вы знаете, как ей пользоваться)
|
||||
Чтобы убедиться, что `BBR` включён правильно, выполните команду:
|
||||
|
||||
:::
|
||||
```shell
|
||||
sysctl net.ipv4.tcp_congestion_control
|
||||
```
|
||||
|
||||
4. Редактируем файл конфигурации `sysctl.conf` и включаем `BBR`:
|
||||
В результате вы должны увидеть что-то вроде этого:
|
||||
|
||||
```shell
|
||||
sudo nano /etc/sysctl.conf
|
||||
```
|
||||
```
|
||||
net.ipv4.tcp_congestion_control = bbr
|
||||
```
|
||||
|
||||
::: warning
|
||||
В Debian 10 можно без проблем использовать файл `/etc/sysctl.conf`. Однако, если вы используете другой дистрибутив Linux или не устанавливали систему с нуля по этой инструкции, то рекомендуется создать папку `/etc/sysctl.d/` и добавлять свои файлы конфигурации в неё, например, `/etc/sysctl.d/vpsadmin.conf`. Это обеспечит совместимость с другими дистрибутивами, поскольку в некоторых из них, начиная с версии `systemd` 207, параметры из файла `/etc/sysctl.conf` не читаются. Использование отдельного файла конфигурации также предотвратит потерю настроек при случайном перезаписывании файла `/etc/sysctl.conf`.
|
||||
:::
|
||||
Если вас смущает `ipv4` в названии — не переживайте, это лишь историческое наследие в имени параметра, настройка одинаково действует и для IPv6.
|
||||
|
||||
5. Добавляем следующие строки в конец файла:
|
||||
Чтобы убедиться, что алгоритм `fq` используется, выполните команду:
|
||||
|
||||
```
|
||||
net.core.default_qdisc=fq
|
||||
net.ipv4.tcp_congestion_control=bbr
|
||||
```
|
||||
```shell
|
||||
sysctl net.core.default_qdisc
|
||||
```
|
||||
|
||||
6. Перезагружаем VPS, чтобы изменения вступили в силу:
|
||||
В результате вы должны увидеть что-то вроде этого:
|
||||
|
||||
```shell
|
||||
sudo reboot
|
||||
```
|
||||
|
||||
7. Весь процесс показан на гифке:
|
||||
|
||||
::: tip
|
||||
На моём VPS поддерживается специальное ядро для облачных серверов, поэтому на гифке я устанавливаю `linux-image-cloud-amd64`. Если вы не уверены, поддерживается ли оно на вашем VPS, то установите обычное ядро `linux-image-amd64`, как показано в пункте 3.
|
||||
:::
|
||||
|
||||

|
||||
|
||||
8. Проверяем, что `BBR` включен
|
||||
|
||||
Чтобы убедиться, что модуль `BBR` загружен, выполните команду:
|
||||
|
||||
```shell
|
||||
lsmod | grep bbr
|
||||
```
|
||||
|
||||
В результате вы должны увидеть что-то вроде этого:
|
||||
|
||||
```
|
||||
tcp_bbr
|
||||
```
|
||||
|
||||
Чтобы убедиться, что алгоритм `fq` используется, выполните команду:
|
||||
|
||||
```shell
|
||||
lsmod | grep fq
|
||||
```
|
||||
|
||||
В результате вы должны увидеть что-то вроде этого:
|
||||
|
||||
```
|
||||
sch_fq
|
||||
```
|
||||
```
|
||||
net.core.default_qdisc = fq
|
||||
```
|
||||
|
||||
## 7.8 Оптимизация сервера: автоматическое перенаправление HTTP на HTTPS
|
||||
|
||||
|
||||
@@ -18,22 +18,17 @@
|
||||
| `cmd-12` | `wget` | Загрузка файла/страницы из сети | [Глава об управлении сертификатами](./ch06-certificates.md) |
|
||||
| `cmd-13` | `acme.sh` | Управление сертификатами с помощью acme.sh | [Глава об управлении сертификатами](./ch06-certificates.md) |
|
||||
| `cmd-14` | `rm` | Удаление файлов/папок | [Глава о Xray сервере](./ch07-xray-server.md) |
|
||||
| `cmd-15` | `crontab -e` | Редактирование crontab текущего пользователя | [Глава о Xray сервере](./ch07-xray-server.md) |
|
||||
| `cmd-16` | `touch` | Создание пустого файла | [Глава о Xray сервере](./ch07-xray-server.md) |
|
||||
| `cmd-17` | `systemctl` | Базовые команды управления сервисами systemd | [Глава о Xray сервере](./ch07-xray-server.md) |
|
||||
| `cmd-18` | `reboot` | Перезагрузка Linux | [Глава о Xray сервере](./ch07-xray-server.md) |
|
||||
| `cmd-15` | `touch` | Создание пустого файла | [Глава о Xray сервере](./ch07-xray-server.md) |
|
||||
| `cmd-16` | `systemctl` | Базовые команды управления сервисами systemd | [Глава о Xray сервере](./ch07-xray-server.md) |
|
||||
| `cmd-17` | `reboot` | Перезагрузка Linux | [Глава о Xray сервере](./ch07-xray-server.md) |
|
||||
|
||||
## 2. Индекс важных конфигурационных файлов Linux
|
||||
|
||||
| Номер | Расположение файла | Описание файла | Глава |
|
||||
| :-------: | :-------------------------------------- | :--------------------------------------- | :--------------------------------------------: |
|
||||
| `conf-01` | `/etc/ssh/sshd_config` | Конфигурация SSH сервера | [Глава о удаленном подключении](./ch03-ssh.md) |
|
||||
| `conf-02` | `/etc/nginx/nginx.conf` | Конфигурация Nginx | [Глава о создании сайта](./ch05-webpage.md) |
|
||||
| `conf-03` | `/etc/apt/sources.list` | Список репозиториев APT | [Глава о Xray сервере](./ch07-xray-server.md) |
|
||||
| `conf-04` | `/etc/apt/sources.list.d/vpsadmin.list` | Список пользовательских репозиториев APT | [Глава о Xray сервере](./ch07-xray-server.md) |
|
||||
| `conf-05` | `crontab -e` | Crontab текущего пользователя | [Глава о Xray сервере](./ch07-xray-server.md) |
|
||||
| `conf-06` | `/etc/sysctl.conf` | Настройки ядра Linux | [Глава о Xray сервере](./ch07-xray-server.md) |
|
||||
| `conf-07` | `/etc/sysctl.d/vpsadmin.conf` | Пользовательские настройки ядра Linux | [Глава о Xray сервере](./ch07-xray-server.md) |
|
||||
| Номер | Расположение файла | Описание файла | Глава |
|
||||
| :-------: | :-------------------------- | :------------------------------------ | :--------------------------------------------: |
|
||||
| `conf-01` | `/etc/ssh/sshd_config` | Конфигурация SSH сервера | [Глава о удаленном подключении](./ch03-ssh.md) |
|
||||
| `conf-02` | `/etc/nginx/nginx.conf` | Конфигурация Nginx | [Глава о создании сайта](./ch05-webpage.md) |
|
||||
| `conf-03` | `/etc/sysctl.d/99-bbr.conf` | Пользовательские настройки ядра Linux | [Глава о Xray сервере](./ch07-xray-server.md) |
|
||||
|
||||
## 3. Индекс важных файлов Xray
|
||||
|
||||
|
||||
Reference in New Issue
Block a user