搭建nginx+fcgi并使用frp实现内外网访问

使用holer访问,并且nginx与fcgi的搭建都是在下面这边文章当中

https://blog.csdn.net/qq_40282557/article/details/116161550

现在就是使用frp进行内网穿透

1、工具准备

(1)服务器,本文使用的是腾讯云服务器
(2)一个域名,解析到服务器地址
(3)frp的两个包,也就是服务器运行和本地的运行的
下载地址为

https://github.com/fatedier/frp/releases/

服务器建议用下面代码方式进行下载

wget https://github.com/fatedier/frp/releases/download/版本/架构

2、配置文件

2.1配置frps.ini
[common]
#客户端连接的端口
bind_port = 7000
vhost_http_port = 6001#这就是http访问时的端口
subdomain_host = www.*********#自己的域名
2.2配置frpc.ini
[common]
server_addr = www.*******
server_port = 7000#要和frps.ini一致

[ssh]#ssh连接的方式
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6000

[http]
#连接方式  http
type = http
#内网服务器地址
#local_ip = 192.168.0.199
local_ip = 127.0.0.1
#内网服务器端口
local_port = 80#主要是端口一定要配置好
#外网的域名
custom_domains = www.**********
2.3配置nginx

打开文件nginx.conf默认在/usr/local/nginx/conf
下面添加sever为

 server {
        listen       80;
        server_name  www.**********;
        location ~ \.cgi$ {
        	fastcgi_pass 127.0.0.1:8088;
                fastcgi_index index.cgi;
                fastcgi_param SCRIPT_FILENAME fcgi$fastcgi_script_name;
                include fastcgi_params;
        }  
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

3、启动服务

3.1在服务器上运行

运行frps

 ./frps -c ./frps.ini
3.1在客户端运行

(1)运行fcgi

/usr/local/nginx/sbin/spawn-fcgi -a 127.0.0.1 -p 8088 -f /usr/local/nginx/sbin/fcgi

(2)重启nginx

sudo ./nginx -s reload

(3)运行frpc

./frpc -c ./frpc.ini

服务器端的运行情况:
在这里插入图片描述
客户端运行情况:
在这里插入图片描述
输入

域名+端口号+fcgi程序

即可进行访问
在这里插入图片描述
在服务器一直运行的命令:
服务端: nohup ./frps -c frps.ini >/dev/null 2>&1 &
客户端: nohup ./frpc -c frpc.ini >/dev/null 2>&1 &

说明:>/dev/null 2>&1 &,表示丢弃。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值