[GH-ISSUE #5256] [Feature]: SOCKS proxy for specific nodes #3684

Closed
opened 2026-10-31 20:34:13 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @mshahr1 on GitHub (Jun 13, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5256

Adding an option to enable a SOCKS proxy for specific nodes: The reason for this suggestion is that, due to the current network conditions in Iran, nodes located outside the country are not easily accessible. Having an option to route API requests through a proxy would be a massive help.

Thank you again for all your hard work!

Describe the solution you'd like

On node tabs, enabling socks5 proxy for specific node

Alternatives you've considered

No response

Concrete use case

No response

Mockups, screenshots, or examples

No response

Which parts of the panel would this affect?

No response

Are you willing to help?

  • I'd like to implement this feature myself and open a PR.
  • I can help test once a PR is open.

Before submitting

  • I searched existing issues and this feature has not been requested.
  • This feature request is written in English.
Originally created by @mshahr1 on GitHub (Jun 13, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5256 ### Is your feature request related to a problem? Adding an option to enable a SOCKS proxy for specific nodes: The reason for this suggestion is that, due to the current network conditions in Iran, nodes located outside the country are not easily accessible. Having an option to route API requests through a proxy would be a massive help. Thank you again for all your hard work! ### Describe the solution you'd like On node tabs, enabling socks5 proxy for specific node ### Alternatives you've considered _No response_ ### Concrete use case _No response_ ### Mockups, screenshots, or examples _No response_ ### Which parts of the panel would this affect? _No response_ ### Are you willing to help? - [x] I'd like to implement this feature myself and open a PR. - [x] I can help test once a PR is open. ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this feature has not been requested. - [x] This feature request is written in English.
Author
Owner

@github-actions[bot] commented on GitHub (Jun 13, 2026):

This feature does not currently exist. Confirmed by reading the source: the Node struct (internal/database/model/model.go, lines 450–509) has no proxy field, and internal/web/runtime/remote.go (line 26) uses a single shared remoteHTTPClient for all node API calls with no per-node proxy support.

The good news for a PR author is that most of the infrastructure already exists.

What is already in the codebase

  • internal/util/netproxy/netproxy.go — a reusable NewHTTPClient(proxyURL string, timeout time.Duration) that builds a standard *http.Client with a SOCKS5 (or HTTP/HTTPS) dialer, backed by golang.org/x/net/proxy. Accepted formats: socks5://host:port, socks5://user:pass@host:port, http://..., https://.... An empty string means direct connection.
  • internal/web/service/node.go — the nodeHTTPClientFor(n *model.Node) function (around line 61) already demonstrates creating a node-specific *http.Client based on per-row settings (TlsVerifyMode, PinnedCertSha256). The proxy extension follows exactly the same pattern.
  • internal/web/service/setting.go (GetTgBotProxy()) and internal/web/service/tgbot/tgbot.go — show a working panel-wide egress proxy applied to an outbound HTTP client. Per-node proxy is the same concept scoped to the row.

Minimal set of changes a PR would need

  1. Database model (internal/database/model/model.go, Node struct): add one field, e.g.

    ProxyUrl string `json:"proxyUrl" form:"proxyUrl" gorm:"column:proxy_url"`
    

    GORM auto-migration will add the column automatically.

  2. Node service (internal/web/service/node.go, normalize() and Update()): validate the URL format (accept empty string as "no proxy"); add "proxy_url" to the updates map in Update().

  3. Remote runtime (internal/web/runtime/remote.go): instead of always using the package-level remoteHTTPClient, have the Remote struct hold its own *http.Client built in NewRemote() via netproxy.NewHTTPClient(n.ProxyUrl, remoteHTTPTimeout). Fall back to the shared client when ProxyUrl is empty if you want to preserve connection pooling for the common case.

  4. Frontend schema (frontend/src/schemas/node.ts): add proxyUrl: z.string().optional().

  5. Frontend form (frontend/src/pages/nodes/NodeFormModal.tsx): add a Form.Item for the proxy URL with a placeholder such as socks5://127.0.0.1:1080 or socks5://user:pass@host:port.

Relationship to #4718

Issue #4718 is about the Telegram bot's SOCKS5 proxy (a panel-wide setting, different subsystem). This request is independent — it concerns per-node API connectivity, not the Telegram bot.

To proceed, open a PR against main with the changes above. Please include the ProxyUrl field validation and a note in the PR description about which proxy schemes are accepted.

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:4697487996 --> @github-actions[bot] commented on GitHub (Jun 13, 2026): This feature does not currently exist. Confirmed by reading the source: the `Node` struct (`internal/database/model/model.go`, lines 450–509) has no proxy field, and `internal/web/runtime/remote.go` (line 26) uses a single shared `remoteHTTPClient` for all node API calls with no per-node proxy support. The good news for a PR author is that most of the infrastructure already exists. **What is already in the codebase** - `internal/util/netproxy/netproxy.go` — a reusable `NewHTTPClient(proxyURL string, timeout time.Duration)` that builds a standard `*http.Client` with a SOCKS5 (or HTTP/HTTPS) dialer, backed by `golang.org/x/net/proxy`. Accepted formats: `socks5://host:port`, `socks5://user:pass@host:port`, `http://...`, `https://...`. An empty string means direct connection. - `internal/web/service/node.go` — the `nodeHTTPClientFor(n *model.Node)` function (around line 61) already demonstrates creating a node-specific `*http.Client` based on per-row settings (`TlsVerifyMode`, `PinnedCertSha256`). The proxy extension follows exactly the same pattern. - `internal/web/service/setting.go` (`GetTgBotProxy()`) and `internal/web/service/tgbot/tgbot.go` — show a working panel-wide egress proxy applied to an outbound HTTP client. Per-node proxy is the same concept scoped to the row. **Minimal set of changes a PR would need** 1. **Database model** (`internal/database/model/model.go`, `Node` struct): add one field, e.g. ```go ProxyUrl string `json:"proxyUrl" form:"proxyUrl" gorm:"column:proxy_url"` ``` GORM auto-migration will add the column automatically. 2. **Node service** (`internal/web/service/node.go`, `normalize()` and `Update()`): validate the URL format (accept empty string as "no proxy"); add `"proxy_url"` to the `updates` map in `Update()`. 3. **Remote runtime** (`internal/web/runtime/remote.go`): instead of always using the package-level `remoteHTTPClient`, have the `Remote` struct hold its own `*http.Client` built in `NewRemote()` via `netproxy.NewHTTPClient(n.ProxyUrl, remoteHTTPTimeout)`. Fall back to the shared client when `ProxyUrl` is empty if you want to preserve connection pooling for the common case. 4. **Frontend schema** (`frontend/src/schemas/node.ts`): add `proxyUrl: z.string().optional()`. 5. **Frontend form** (`frontend/src/pages/nodes/NodeFormModal.tsx`): add a `Form.Item` for the proxy URL with a placeholder such as `socks5://127.0.0.1:1080` or `socks5://user:pass@host:port`. **Relationship to #4718** Issue #4718 is about the Telegram bot's SOCKS5 proxy (a panel-wide setting, different subsystem). This request is independent — it concerns per-node API connectivity, not the Telegram bot. To proceed, open a PR against `main` with the changes above. Please include the `ProxyUrl` field validation and a note in the PR description about which proxy schemes are accepted. *This reply was generated automatically; a maintainer may follow up.*
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#3684
No description provided.