# NAT建站-反代WebSocket

{% hint style="info" %}
流程示意圖

VPS部署V2+WebSocket --> NAT建站建立站點 --> 添加反向代理 --> 反代VPS的V2+WS --> 修改反代配置文件 --> 完成✅
{% endhint %}

#### 以V2-WebSocket為例，並默認您已經成功「自建DDNS」

{% content-ref url="/pages/-M-ZudYxxvEiAhhc-t9c" %}
[自建DDNS說明-ChangeIP](/anyhk/ddns/ddns-changeip.md)
{% endcontent-ref %}

{% content-ref url="/pages/-M-\_LdrBl-RnPqoVydIp" %}
[自建DDNS說明-Dynu.com](/anyhk/ddns/ddns-dynu.md)
{% endcontent-ref %}

#### 假設條件

| DDNS域名                | ip.myddns.dynu.net |
| --------------------- | ------------------ |
| VPS 內網IP              | 10.0.0.2           |
| V2 WebSocket 端口       | 8888               |
| V2 Server監聽           | 0.0.0.0            |
| WebSocket的目錄或路徑（path） | /ws                |

![](/files/-M0a_hyRZuEHm4m7PUTE)

![](/files/-M0aaUrT6d7R8Y8PUnN4)

{% hint style="warning" %}
如提示已超過每日免費證書限額，沒關係，繼續往下看到最後的不使用TLS方式。

待改天證書申請成功後再啟用TLS。
{% endhint %}

![](/files/-M0aapxdFiV7ip0umhQ8)

![](/files/-M0abUHXP2iLaGnvXpoT)

![](/files/-M0acRxHRD3j7NXrSmUa)

![](/files/-Mf3VZ8tn1hATQmhCiHH)

{% hint style="success" %}
支持反代配置完成
{% endhint %}

> #### 客戶端如何配置？
>
> 服務器地址填寫：您的域名 「**這裏很重要，不要填IP地址**」
>
> 端口填寫：443,2053,2083,2087,2096,8443 都可以
>
> Network填寫：ws
>
> 打開TLS，並填寫TLS服務器名稱：您的ddns

> #### **不想用TLS？「推薦」**
>
> 服務器地址填寫：您的域名「**這裏很重要，不要填IP地址**」
>
> 端口填寫：80,8080,8880,2052,2082,2086,2095 都可以
>
> Network填寫：ws
>
> 不打開TLS

{% hint style="danger" %}
無論是否開啟TLS，此處都無須打開。
{% endhint %}

![](/files/-M6LyEAGII3kPBMjHvqs)

{% hint style="info" %}
HTTP可用端口：80,8080,8880,2052,2082,2086,2095

HTTPS可用端口：443,2053,2083,2087,2096,8443
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.anyhk.net/anyhk/nat-jian-zhan/websocket.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
