环境:
阿里云服务器:47.105.125.22
内网linux+docker服务器:192.168.56.10
内网windows服务器
1、服务端
nginx配置文件
server {
listen 80;
server_name *.wdl.com;
location / {
root /home/nginx/html;
try_files $uri $uri/ /index.html late;
index index.html index.htm;
add_header 'Access-Control-Allow-Origin' *;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT';
add_header 'Access-Control-Allow-Headers' *;
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
if ($request_method = 'OPTIONS') {
return 204;
}
}
location /large-model-frptest/ {
proxy_pass http://47.105.125.22:7001;
proxy_redirect http://$host/ http://$http_host/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
在阿里云服务器新建一个frp目录,在这个目录下面新建frpc.ini文件夹和docker-compose.yml文件夹
frps.ini文件内容
[common]
bind_addr = 0.0.0.0
bind_port = 7000
vhost_http_port = 7001
privilege_token = wdl@qwe..$test
docker-compose.yml文件内容
version: '3.5'
services:
frps:
restart: always
volumes:
- './frps.ini:/etc/frp/frps.ini'
container_name: frps
image: snowdreamtech/frps:0.39.1
ports:
- "7000:7000"
- "7001:7001"
进上面新建的frp这个目录,执行下面命令启动frp
docker-compose up -d
2、内网服务器linux
新建一个frp目录,在这个目录下新建docker-compose.yml和frps.ini文件夹
frps.ini文件内容
[common]
server_addr = 47.105.125.22
server_port = 7000
privilege_token = wdl@qwe..$04
[httpname]
type = http
local_port = 8085
local_ip = 192.168.56.10
custom_domains = ai.wdl.com
docker-compose.yml文件内容
version: '3.5'
services:
frps:
restart: always
volumes:
- './frpc.ini:/etc/frp/frpc.ini'
container_name: frpc
image: snowdreamtech/frpc:0.39.1
进到frp目录下,执行
docker-compose up -d
3、内网windows服务器
下载frpWindows客户端,下载地址,下载Windows的amd版本。
https://github.com/fatedier/frp/releases/tag/v0.39.1
修改frpc.ini文件
[common]
server_addr = 47.105.125.22
server_port = 7000
privilege_token = wdl@qwe..$test
[httpname1]
type = http
local_port = 8085
local_ip = 127.0.0.1
custom_domains = ai.wdl.com
cmd命令框进到下载的这个frp客服端目录。执行下面命令启动
frpc.exe -c frpc.ini
可以通过 http://ai.wdl.com//large-model-frptest/xxx/xxx
备注,阿里云服务要开放7000端口和7001端口
其他参考
https://www.jianshu.com/p/262cacfb9f9a
https://blog.csdn.net/sinat_14899485/article/details/123015843