Rain's 碎碎念 Rain's 碎碎念
首页
关于

Rain

证明自己存在过
首页
关于
  • 拿到新的VPS/服务器后需要做的各种操作
    • 0. 测试机器性能等各种
    • 1. 修改密码
    • 2. 修改ssh端口号
    • 3. 安装nginx
    • 4. 安装acme
    • 5. 配置域名解析
    • 6. 申请域名证书
    • 7. 修改网站配置文件
    • 8. 上传网站源码到目录,并检查网站是否可正常访问
    • 9. 安装X-UI面板,并配置相关协议及客户端测试(可选,如果你知道是用于干什么的)
    • 10. 安装deeplx(可选,如果你知道是用于干什么的)
    • 11. 安装tuic v5,并配置相关协议及客户端测试(可选,如果你知道是用于干什么的)
    • 12. 强制更新域名证书(如果域名证书过期了,或者其他原因可以使用一下命令手动更新)
  • 使用CDN后,Nginx如何获取访客(客户端)真实IP
  • 自建KMS服务器
  • Oracle Cloud备忘
  • 杂项
Rain
2024-08-08
目录

拿到新的VPS/服务器后需要做的各种操作

提示

说明:一般我们拿到新的VPS/服务器后都要做一些基础的配置更改,使服务器更加安全,以下仅记录自己的常用步骤 系统版本Ubuntu

# 0. 测试机器性能等各种

# 融合怪测试
curl -L https://gitlab.com/spiritysdx/za/-/raw/main/ecs.sh -o ecs.sh && chmod +x ecs.sh && bash ecs.sh
1
2

# 1. 修改密码

sudo passwd root
1

# 2. 修改ssh端口号

vi /etc/ssh/sshd_config
# 修改完成后 重启ssh服务
/etc/init.d/ssh restart
1
2
3

# 3. 安装nginx

apt-get update
apt-get install nginx
nginx -v
1
2
3

# 4. 安装acme

curl https://get.acme.sh | sh -s email=zxia254@gmail.com
source ~/.bashrc
acme.sh  --version
1
2
3

# 5. 配置域名解析

https://dash.cloudflare.com/

不要选择cf代理dns 最后根据实际情况再看是否需要cf代理域名

# 6. 申请域名证书

acme.sh --issue -d 你的域名 -w /var/www/html/ # 根据需要 -server letsencrypt
# 泛域名申请 cf为例
export CF_Key=""
export CF_Email=""
acme.sh --issue --dns dns_cf -d 域名 -d *.域名
1
2
3
4
5

# 7. 修改网站配置文件

cd /etc/nginx/conf.d/
1
server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;
        
        gzip on;
        gzip_http_version 1.1;
        gzip_vary on;
        gzip_comp_level 6;
        gzip_proxied any;
        gzip_types text/plain text/css application/json application/javascript application/x-javascript text/javascript;

        server_name 你的域名;

        ssl_certificate acme申请的cer路径;
        ssl_certificate_key acme申请的key路径;
        ssl_protocols  TLSv1.2 TLSv1.3;
        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;
        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

        location / {
          root   /var/www/html;
          index index.html;
        }
  		# 代理翻墙协议
        location /somepath {
          if ($http_upgrade != "websocket") {
            return 404;
          }
          proxy_pass  http://127.0.0.1:port;
          proxy_redirect off;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_read_timeout 52w;
        }
  		# 代理deeplx
        location /somepathtoo {
          proxy_pass  http://127.0.0.1:port/translate;
          proxy_set_header Authorization "Bearer token";
        }


    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
      root   /var/www;
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

# 8. 上传网站源码到目录,并检查网站是否可正常访问

scp -P 端口 -r * root@ip:/var/www/html/
1

# 9. 安装X-UI面板,并配置相关协议及客户端测试(可选,如果你知道是用于干什么的)

bash <(wget -qO- https://raw.githubusercontent.com/sing-web/x-ui/main/install_CN.sh)
# 注意 nginx的转发里没有配置https 所以tls验证在服务端是不需要的,已经由nginx做了
# 配置时注意 端口 和 ws的路径 跟网站配置文件里的一致即可
1
2
3

# 10. 安装deeplx(可选,如果你知道是用于干什么的)

bash <(curl -Ls https://owo.nz/deeplx)
# 设置端口及访问需要的token -p 端口 -token token
vi /etc/systemd/system/deeplx.service
# 重新加载配置及设置开机启动
systemctl daemon-reload
systemctl enable deeplx
systemctl restart deeplx
1
2
3
4
5
6
7

# 11. 安装tuic v5,并配置相关协议及客户端测试(可选,如果你知道是用于干什么的)

# 先准备好域名 因为安装时会关闭nginx 导致无法通过代理访问 cloudflare
wget -P /root -N --no-check-certificate "https://raw.githubusercontent.com/mack-a/v2ray-agent/master/install.sh" && chmod 700 /root/install.sh && /root/install.sh

vasma -> 2 -> 2 -> 9
1
2
3
4

# 12. 强制更新域名证书(如果域名证书过期了,或者其他原因可以使用一下命令手动更新)

acme.sh --renew -d 域名 --force
acme.sh --force --cron
1
2
#VPS
上次更新: 2025/06/14, 17:24:26
使用CDN后,Nginx如何获取访客(客户端)真实IP

使用CDN后,Nginx如何获取访客(客户端)真实IP→

最近更新
01
Oracle Cloud备忘
06-14
02
自建KMS服务器
05-08
03
快速从命令后启动IDE
05-03
更多文章>
Theme by Vdoing | Copyright © 2024-2025 Rain
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式