Browse Source

spring-boot-demo-social 完成

pull/1/head
Yangkai.Shen 5 years ago
parent
commit
d4771564ad
2 changed files with 122 additions and 4 deletions
  1. +122
    -4
      spring-boot-demo-social/README.md
  2. BIN
      spring-boot-demo-social/assets/image-20190615165843639.png

+ 122
- 4
spring-boot-demo-social/README.md View File

@@ -20,21 +20,139 @@

#### 1.2.1. frp服务端搭建

服务端搭建在上一步准备的公网服务器上,因为服务器是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) 。
服务端搭建在上一步准备的公网服务器上,因为服务器是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) 。

1. 下载安装包

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

2. 解压安装包

```shell
$ tar -zxvf frp_0.27.0_linux_amd64.tar.gz
```

#### 1.2.2. frp客户端搭建
3. 修改配置文件

```shell
$ cd frp_0.27.0_linux_amd64
$ vim frps.ini
[common]
bind_port = 7100
vhost_http_port = 7200
```

4. 启动frp服务端

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

#### 1.2.2. frp客户端搭建

客户端搭建在本地的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) 。

1. 下载安装包

```shell
$ wget https://github.com/fatedier/frp/releases/download/v0.27.0/frp_0.27.0_darwin_amd64.tar.gz
```

2. 解压安装包

```shell
$ tar -zxvf frp_0.27.0_darwin_amd64.tar.gz
```

3. 修改配置文件,配置服务端ip端口及监听的域名信息

```shell
$ cd frp_0.27.0_darwin_amd64
$ vim frpc.ini
[common]
server_addr = 120.92.169.103
server_port = 7100
[web]
type = http
local_port = 8080
custom_domains = oauth.xkcoding.com
```

4. 启动frp客户端

```shell
$ ./frpc -c frpc.ini
2019/06/15 16:48:52 [I] [service.go:221] login to server success, get run id [8bb83bae5c58afe6], server udp port [0]
2019/06/15 16:48:52 [I] [proxy_manager.go:137] [8bb83bae5c58afe6] proxy added: [web]
2019/06/15 16:48:52 [I] [control.go:144] [web] start proxy success
```

### 1.3. 配置域名解析

前往阿里云DNS解析,将域名解析到我们的公网服务器上,比如我的就是将 `oauth.xkcoding.com -> 120.92.169.103`

![image-20190615165843639](assets/image-20190615165843639.png)

### 1.4. nginx代理

nginx 的搭建就不在此赘述了,只说配置

```nginx
server {
listen 80;
server_name oauth.xkcoding.com;
location / {
proxy_pass http://127.0.0.1:7200;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_buffering off;
sendfile off;
proxy_max_temp_file_size 0;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_temp_file_write_size 64k;
proxy_http_version 1.1;
proxy_request_buffering off;
}
}
```

测试配置文件是否有问题

```shell
$ nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
```

重新加载配置文件,使其生效

```shell
$ nginx -s reload
```

> 现在当我们在浏览器输入 `oauth.xkcoding.com` 的时候,网络流量其实会经历以下几个步骤:
>
> 1. 通过之前配的DNS域名解析会访问到我们的公网服务器 `120.92.169.103` 的 80 端口
> 2. 再经过 nginx,代理到本地的 7200 端口
> 3. 再经过 frp 穿透到我们的 Mac 电脑的 8080 端口
> 4. 此时 8080 就是我们的应用程序端口

### 1.4. 第三方平台申请
### 1.5. 第三方平台申请





BIN
spring-boot-demo-social/assets/image-20190615165843639.png View File

Before After
Width: 2424  |  Height: 468  |  Size: 118 kB

Loading…
Cancel
Save