# 使用systemctl来进行管理 root@VM-0-15-ubuntu:/app/soft/frp# vim /usr/lib/systemd/system/frps.service [Unit] Description=frps service
[Service] ExecStart=/app/soft/frp/frps -c /app/soft/frp/frps.ini Restart=always # Restart service after 10 seconds if the dotnet service crashes: RestartSec=10 KillSignal=SIGINT SyslogIdentifier=frp-service User=root
root@VM-0-15-ubuntu:/app/soft/frp# cd /app/nginx/conf/conf.d/ root@VM-0-15-ubuntu:/app/nginx/conf/conf.d# vim frp_web.conf server { listen 80; server_name *.frp.xxxx.com frp.yxxxx.com;
} # 防止爬虫抓取 if ($http_user_agent ~* "360Spider|JikeSpider|Spider|spider|bot|Bot|2345Explorer|curl|wget|webZIP|qihoobot|Baiduspider|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Yahoo! Slurp|Yahoo! Slurp China|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot|ia_archiver|Tomato Bot|NSPlayer|bingbot") { return 403; } }
客户端安装
1 2 3 4 5 6 7 8 9 10 11 12 13
# 下载frp压缩包 root@mongodb-server-25:/app# wget http://image.oaali.com/down/Other/frp_0.48.0_linux_amd64.tar.gz root@mongodb-server-25:/app# ls frp_0.48.0_linux_amd64.tar.gz mysql root@mongodb-server-25:/app# tar xf frp_0.48.0_linux_amd64.tar.gz root@mongodb-server-25:/app# ls frp_0.48.0_linux_amd64 frp_0.48.0_linux_amd64.tar.gz mysql root@mongodb-server-25:/app# mv frp_0.48.0_linux_amd64 frp root@mongodb-server-25:/app# ls frp frp_0.48.0_linux_amd64.tar.gz mysql root@mongodb-server-25:/app# cd frp # 在客户端端我们不需要服务端的可执行程序和配置,为了避免误操作,我们可以先删除掉所有服务端的的配置 root@mongodb-server-25:/app/frp# rm -rf frps*
root@mongodb-server-25:/app/frp# vim /usr/lib/systemd/system/frpc.service [Unit] Description=frp service
[Service] ExecStart=/app/frp/frpc -c /app/frp/frpc.ini Restart=always # Restart service after 10 seconds if the dotnet service crashes: RestartSec=10 KillSignal=SIGINT SyslogIdentifier=frp-service User=root
# 先创建好静态页面以及目录 root@mongodb-server-25:~# cd /var/www/ root@mongodb-server-25:/var/www# ls html root@mongodb-server-25:/var/www# cd html/ root@mongodb-server-25:/var/www/html# ls index.nginx-debian.html root@mongodb-server-25:/var/www/html# mkdir web root@mongodb-server-25:/var/www/html# cd web/ root@mongodb-server-25:/var/www/html/web# ls root@mongodb-server-25:/var/www/html/web# vim index.html root@mongodb-server-25:/var/www/html/web# cat index.html <h1>This is 8585 Port!</h1> # 创建虚拟主机 root@mongodb-server-25:/etc/nginx/conf.d# vim web_a.conf server { listen 8585; server_name 172.20.17.25;
location / { root /var/www/html/web; index index.html index.htm; } } root@mongodb-server-25:/etc/nginx/conf.d# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful root@mongodb-server-25:/etc/nginx/conf.d# nginx -s reload root@mongodb-server-25:/etc/nginx/conf.d# ss -tnl State Recv-Q Send-Q Local Address:Port Peer Address:Port Process LISTEN 0 511 0.0.0.0:8585 0.0.0.0:* LISTEN 0 511 0.0.0.0:80 0.0.0.0:*