This repository has been archived by the owner on Dec 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
110 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## Language | ||
Language | ||
> [简体中文](../为同一主机的443端口配置HTTPS反向代理.md) | ||
> ***English*** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## Language | ||
Language | ||
> [简体中文](../README.md) | ||
> ***English*** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## Language | ||
Language | ||
> [简体中文](../配置HTTP反向代理且合并端口.md) | ||
> ***English*** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## Language | ||
Language | ||
> [简体中文](../配置HTTPS反向代理且合并端口.md) | ||
> ***English*** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## Language | ||
Language | ||
> [简体中文](../配置HTTPS反向代理.md) | ||
> ***English*** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## Language | ||
Language | ||
> ***简体中文*** | ||
> [English](english/443.md) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
[<=点此返回README](README.md) | ||
|
||
*** | ||
# 理论基础 | ||
> 所有相关的文章都基于理论基础。如果直接按照文章里的方式操作是没问题的,但一些特殊场景不能完全按照文章里的操作,因此需要自行基于一些理论进行修改。 | ||
> 本文的“Web端”指Web后端,“浏览器”指前端。 | ||
> 本文**不是**MCSManager官方开发人员写的。 | ||
*** | ||
## 连接Daemon | ||
### 1. 浏览器 → Web端 → Daemon端 | ||
浏览器检查Daemon在线状态、获取Daemon的所有实例、管理Daemon的文件、修改Daemon的文件等绝大多数操作都会由Web端代理。 | ||
|
||
|
||
|
||
### 2. 浏览器 → Daemon端 | ||
连接实例终端、直接下载或直接上传文件,对应以下路径开头 | ||
> /socket.io/ | ||
> /upload/ | ||
> /download/ | ||
如果节点地址不填协议头,那么浏览器自动使用连接Web端时的协议(http对应ws,https对应wss)。 | ||
如果节点地址填了协议头,那么浏览器会使用填写的协议头。 | ||
如果节点地址去除协议头后,以 `localhost` 或 `127.0.0.` 开头,则浏览器会将域名替换成连接Web端时使用的域名。[[参考mcsm9的前端相关源码]](https://github.com/MCSManager/UI/blob/master/src/app/service/protocol.js#L131) | ||
例如以下场景 | ||
|
||
1. Web使用`http://example.com:12333`, | ||
Daemon填写域名 `localhost` 端口 `12444`, | ||
那么浏览器会使用 `ws://example.com:12444` 或 `http://example.com:12444` 连接Daemon。 | ||
|
||
1. Web使用`https://example.com:12333`, | ||
Daemon填写域名 `localhost` 端口 `12444`, | ||
那么浏览器会使用 `wss://example.com:12444` 或 `https://example.com:12444` 连接Daemon。 | ||
|
||
1. Web使用`https://example.com:12333`, | ||
Daemon填写域名 `ws://localhost` 端口 `12444`, | ||
那么浏览器会使用 `ws://example.com:12444` 或 `http://example.com:12444` 连接Daemon, | ||
**然后因为浏览器阻止https页面使用http请求资源,所以连接失败**。 | ||
|
||
1. Web使用`https://example.com:12333`, | ||
Daemon填写域名 `wss://mcsmdaemon.example.com` 端口 `12444`, | ||
那么浏览器会使用 `wss://mcsmdaemon.example.com:12444` 或 `https://mcsmdaemon.example.com:12444` 连接Daemon。 | ||
|
||
|
||
|
||
### 3. Web端 → Daemon端 | ||
Web端会通过 `/socket.io/` 路径的开头连接Daemon,代理大多数操作。 | ||
|
||
修改nginx配置的Daemon端localhost部分的location,然后重载nginx,然后让Web端重新连接Daemon端,会发现一切操作正常进行,验证了上述理论。 | ||
```nginx | ||
server { | ||
# Daemon 端代理后localhost访问HTTP协议端口(可用多个listen监听多个端口) | ||
``` | ||
```nginx | ||
# 开始反向代理 | ||
# 代理Daemon端 | ||
location =/socket.io/ { | ||
``` | ||
|
||
如果节点地址不填协议头,那么Web端自动使用ws协议。 | ||
如果节点地址填了协议头,那么Web端会使用填写的协议头。 | ||
例如以下场景 | ||
|
||
1. Daemon填写域名 `localhost` 端口 `12444`, | ||
那么Web端会使用 `ws://localhost:12444` 连接Daemon。 | ||
|
||
2. Daemon填写域名 `ws://localhost` 端口 `12444`, | ||
那么Web端会使用 `ws://localhost:12444` 连接Daemon。 | ||
|
||
3. Daemon填写域名 `wss://mcsmdaemon.example.com` 端口 `12444`, | ||
那么Web端会使用 `wss://mcsmdaemon.example.com:12444` 连接Daemon。 | ||
|
||
|
||
|
||
*** | ||
## 非常感谢您能阅读我写的教程,希望对你有帮助! | ||
有错误的内容或改进的建议?或者没弄懂怎么配置?[点此编辑并提交issue](../../issues/new)。 | ||
|
||
### 想要分享该文档? | ||
[Gitee 仓库(中国内地访问稳定):](https://gitee.com/bddjr/nginx-proxy-docs-for-mcsm/blob/master/%E7%90%86%E8%AE%BA%E5%9F%BA%E7%A1%80.md) | ||
``` | ||
https://gitee.com/bddjr/nginx-proxy-docs-for-mcsm/blob/master/%E7%90%86%E8%AE%BA%E5%9F%BA%E7%A1%80.md | ||
``` | ||
[Github 仓库:](https://github.com/bddjr/nginx-proxy-docs-for-mcsm/blob/master/%E7%90%86%E8%AE%BA%E5%9F%BA%E7%A1%80.md) | ||
``` | ||
https://github.com/bddjr/nginx-proxy-docs-for-mcsm/blob/master/%E7%90%86%E8%AE%BA%E5%9F%BA%E7%A1%80.md | ||
``` | ||
[Github Page + Cloudflare CDN 网页:](https://proxyformcsm.bddjr.com/%E7%90%86%E8%AE%BA%E5%9F%BA%E7%A1%80.html) | ||
``` | ||
https://proxyformcsm.bddjr.com/%E7%90%86%E8%AE%BA%E5%9F%BA%E7%A1%80.html | ||
``` | ||
|
||
*** | ||
[<=点此返回README](README.md) | ||
|
||
> 源码仓库:<a href="https://github.com/bddjr/nginx-proxy-docs-for-mcsm" target="_blank">nginx-proxy-docs-for-mcsm</a><br/> | ||
> Made by <a href="https://bddjr.cn" target="_blank" rel="noopener">bddjr</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## Language | ||
Language | ||
> ***简体中文*** | ||
> [English](english/https.md) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## Language | ||
Language | ||
> ***简体中文*** | ||
> [English](english/https-merge-ports.md) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## Language | ||
Language | ||
> ***简体中文*** | ||
> [English](english/http-merge-ports.md) | ||
|