Skip to content

Commit d477156

Browse files
committed
✨ spring-boot-demo-social 完成
1 parent 8e4eba0 commit d477156

File tree

2 files changed

+122
-4
lines changed

2 files changed

+122
-4
lines changed

spring-boot-demo-social/README.md

Lines changed: 122 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,139 @@
2020
2121
#### 1.2.1. frp服务端搭建
2222

23-
服务端搭建在上一步准备的公网服务器上,因为服务器是centos7 x64的系统,因此,这里下载安装包版本为amd64的 [frp_0.27.0_linux_amd64.tar.gz](https://github.com/fatedier/frp/releases/download/v0.27.0/frp_0.27.0_linux_amd64.tar.gz)
23+
服务端搭建在上一步准备的公网服务器上,因为服务器是centos7 x64的系统,因此,这里下载安装包版本为linux_amd64的 [frp_0.27.0_linux_amd64.tar.gz](https://github.com/fatedier/frp/releases/download/v0.27.0/frp_0.27.0_linux_amd64.tar.gz)
2424

25+
1. 下载安装包
2526

27+
```shell
28+
$ wget https://github.com/fatedier/frp/releases/download/v0.27.0/frp_0.27.0_linux_amd64.tar.gz
29+
```
2630

31+
2. 解压安装包
2732

33+
```shell
34+
$ tar -zxvf frp_0.27.0_linux_amd64.tar.gz
35+
```
2836

29-
#### 1.2.2. frp客户端搭建
37+
3. 修改配置文件
3038

39+
```shell
40+
$ cd frp_0.27.0_linux_amd64
41+
$ vim frps.ini
42+
43+
[common]
44+
bind_port = 7100
45+
vhost_http_port = 7200
46+
```
3147

48+
4. 启动frp服务端
3249

33-
### 1.3. nginx代理
50+
```shell
51+
$ ./frps -c frps.ini
52+
2019/06/15 16:42:02 [I] [service.go:139] frps tcp listen on 0.0.0.0:7100
53+
2019/06/15 16:42:02 [I] [service.go:181] http service listen on 0.0.0.0:7200
54+
2019/06/15 16:42:02 [I] [root.go:204] Start frps success
55+
```
3456

57+
#### 1.2.2. frp客户端搭建
3558

59+
客户端搭建在本地的Mac上,因此下载安装包版本为darwin_amd64的 [frp_0.27.0_darwin_amd64.tar.gz](https://github.com/fatedier/frp/releases/download/v0.27.0/frp_0.27.0_darwin_amd64.tar.gz)
60+
61+
1. 下载安装包
62+
63+
```shell
64+
$ wget https://github.com/fatedier/frp/releases/download/v0.27.0/frp_0.27.0_darwin_amd64.tar.gz
65+
```
66+
67+
2. 解压安装包
68+
69+
```shell
70+
$ tar -zxvf frp_0.27.0_darwin_amd64.tar.gz
71+
```
72+
73+
3. 修改配置文件,配置服务端ip端口及监听的域名信息
74+
75+
```shell
76+
$ cd frp_0.27.0_darwin_amd64
77+
$ vim frpc.ini
78+
79+
[common]
80+
server_addr = 120.92.169.103
81+
server_port = 7100
82+
83+
[web]
84+
type = http
85+
local_port = 8080
86+
custom_domains = oauth.xkcoding.com
87+
```
88+
89+
4. 启动frp客户端
90+
91+
```shell
92+
$ ./frpc -c frpc.ini
93+
2019/06/15 16:48:52 [I] [service.go:221] login to server success, get run id [8bb83bae5c58afe6], server udp port [0]
94+
2019/06/15 16:48:52 [I] [proxy_manager.go:137] [8bb83bae5c58afe6] proxy added: [web]
95+
2019/06/15 16:48:52 [I] [control.go:144] [web] start proxy success
96+
```
97+
98+
### 1.3. 配置域名解析
99+
100+
前往阿里云DNS解析,将域名解析到我们的公网服务器上,比如我的就是将 `oauth.xkcoding.com -> 120.92.169.103`
101+
102+
![image-20190615165843639](assets/image-20190615165843639.png)
103+
104+
### 1.4. nginx代理
105+
106+
nginx 的搭建就不在此赘述了,只说配置
107+
108+
```nginx
109+
server {
110+
listen 80;
111+
server_name oauth.xkcoding.com;
112+
113+
location / {
114+
proxy_pass http://127.0.0.1:7200;
115+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
116+
proxy_set_header Host $http_host;
117+
proxy_set_header X-Forwarded-Proto $scheme;
118+
proxy_set_header X-Real-IP $remote_addr;
119+
proxy_buffering off;
120+
sendfile off;
121+
proxy_max_temp_file_size 0;
122+
client_max_body_size 10m;
123+
client_body_buffer_size 128k;
124+
proxy_connect_timeout 90;
125+
proxy_send_timeout 90;
126+
proxy_read_timeout 90;
127+
proxy_temp_file_write_size 64k;
128+
proxy_http_version 1.1;
129+
proxy_request_buffering off;
130+
}
131+
}
132+
```
133+
134+
测试配置文件是否有问题
135+
136+
```shell
137+
$ nginx -t
138+
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
139+
nginx: configuration file /etc/nginx/nginx.conf test is successful
140+
```
141+
142+
重新加载配置文件,使其生效
143+
144+
```shell
145+
$ nginx -s reload
146+
```
147+
148+
> 现在当我们在浏览器输入 `oauth.xkcoding.com` 的时候,网络流量其实会经历以下几个步骤:
149+
>
150+
> 1. 通过之前配的DNS域名解析会访问到我们的公网服务器 `120.92.169.103` 的 80 端口
151+
> 2. 再经过 nginx,代理到本地的 7200 端口
152+
> 3. 再经过 frp 穿透到我们的 Mac 电脑的 8080 端口
153+
> 4. 此时 8080 就是我们的应用程序端口
36154
37-
### 1.4. 第三方平台申请
155+
### 1.5. 第三方平台申请
38156

39157

40158

116 KB
Loading

0 commit comments

Comments
 (0)