由于我的服务器没有公网IP,需要云服务器+frp将我的内网服务映射到公网上,且云服务器价格比较贵,需要经常更换(薅羊毛),频繁地配置服务器环境是一件繁琐的事情。
特此记录下将一台新的云服务器配置成满足我的要求所需要的步骤,这样可以节省很多的时间。
持续更新…🏃
云服务器端
frps
配置:
[common]
bind_port = 7000
token = ******
dashboard_port = 7500
vhost_http_port = 8080
# 后台账号
dashboard_user = ******
dashboard_pwd = ******
enable_prometheus = true
log_file = /var/log/frps.log
log_level = info
log_max_days = 1000
nginx
配置:
路径 /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name blog.zzqwtc.top;
location / {
proxy_pass http://127.0.0.1:8080;
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_hide_header X-Powered-By;
}
}
server {
listen 80;
server_name images.zzqwtc.top;
location / {
proxy_pass http://127.0.0.1:8080;
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_hide_header X-Powered-By;
}
}
server {
listen 80;
server_name cloud.zzqwtc.top;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://127.0.0.1:8080;
}
}
server {
listen 80;
server_name zzqwtc.top;
location / {
proxy_pass http://127.0.0.1:8080;
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_hide_header X-Powered-By;
}
}
我的服务器端
frpc
配置:
[common]
server_addr = xxx.xxx.xxx.xxx
server_port = 7000
token = ******
tls_enable = true
[secret_ssh_my_server]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6000
[pigbed]
type = http
local_port = 8000
custom_domains = images.zzqwtc.top
[blog]
type = http
local_port = 4000
custom_domains = blog.zzqwtc.top
[cloudreve]
type = http
local_port = 5212
custom_domains = cloud.zzqwtc.top
nginx
配置:
路径/etc/nginx/sites-available/default
server {
listen 8000 default_server;
listen [::]:8000 default_server;
root /home/zzqwtc/Download/lsky-pro-2.0.4/public;
index index.html index.htm index.nginx-debian.html index.php;
server_name images.zzqwtc.top;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
}
}
路径/etc/nginx/conf.d/default.conf
# 公网 ipv6
server {
listen [::]:80;
server_name zzqwtc.top;
location / {
index index.html;
root /home/zzqwtc/Download/myindex;
}
}
server {
listen [::]:80;
server_name blog.zzqwtc.top;
location / {
index index.html;
root /home/zzqwtc/Download/blog/public;
}
location /admin/ {
proxy_pass http://127.0.0.1:4001;
}
}
server {
listen [::]:80;
server_name images.zzqwtc.top;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:8000;
}
}
server {
listen [::]:80;
server_name cloud.zzqwtc.top;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:5212;
}
}
# 内网穿透 ipv6
server {
listen 4000;
server_name blog.zzqwtc.top;
location / {
index index.html;
root /home/zzqwtc/Download/blog/public;
}
location /admin/ {
proxy_pass http://127.0.0.1:4001;
}
}
server {
listen 5213;
server_name zzqwtc.top;
location / {
index index.html;
root /home/zzqwtc/Download/myindex;
}
}
lsky pro图床
由于 lsky pro2.0
图床基于php-fpm8.1,要求nginx 和 fpm 为同一个用户,我的ngxin配置的是root
用户,但是fpm不允许使用 root
用户,所以使用命令 php-fpm8.1 -R
强制使用root
用户运行
DDNS-go 动态域名解析
systemctl start ddns