[GH-ISSUE #5534] Question: How should Share address strategy, Hosts, and externalProxy work together? #3863

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

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

What are you trying to do?

I am trying to understand how the new Share address strategy setting is supposed to work and how it relates to the old externalProxy behavior.

In previous versions, externalProxy was used to define the address that should be written into exported share links, QR codes, and subscription output when the panel was behind a router / reverse proxy / NAT.

In the current UI, there is a new setting here:

Inbounds -> Edit inbound -> Basics -> Share address strategy

The description says:

Controls which address is written into exported share links, QR codes, and subscription output.

By default, it is set to:

Inbound listen

This looks like it may be a replacement for the old externalProxy setting.

However, even when Share address strategy is set to Inbound listen, the config still contains:

"externalProxy": [
  {
    "forceTls": "same",
    "dest": "XXX.XXX",
    "port": 443,
    "remark": ""
  }
]

When I change Share address strategy to Custom and set a custom address, I do not see any change in the externalProxy config.

So I am not sure what the expected relationship is between these settings.

Is Share address strategy supposed to replace externalProxy, or is it a separate setting?

Should changing Share address strategy to Custom update externalProxy, or is the custom address stored somewhere else?

Also, there is now a Hosts tab, and it is not clear what it is intended for.

The content of the Hosts tab looks like it corresponds to the existing externalProxy config. At least visually, it seems to contain the same type of data as externalProxy.

So I would like to clarify the intended model:

externalProxy
Hosts tab
Inbounds -> Edit inbound -> Basics -> Share address strategy

Are these three parts connected?

If yes, what is the expected workflow for a panel behind a router / reverse proxy where exported share links, QR codes, and subscriptions should use a public external address instead of the inbound listen address?

For example, if the inbound listens locally or behind NAT, but users should connect to:

example.com:443

where should this address be configured now?

Should it be configured in:

Hosts

or:

Inbounds -> Edit inbound -> Basics -> Share address strategy -> Custom

or:

externalProxy

or some combination of them?

The current UI is confusing because Share address strategy sounds like the setting that controls exported share links, but changing it to Custom does not appear to update the visible externalProxy config.

At the same time, the Hosts tab looks like it may be the new UI for externalProxy, but this is not obvious from the UI.

What have you already tried?

No response

3x-ui version

3.4.0

How did you install 3x-ui?

install.sh script

Operating system

Debian 12

Screenshots or config snippets

No response

Before submitting

  • I read the Wiki and searched existing issues.
  • This is a usage question, not a bug report.
  • This question is written in English.
Originally created by @atem32 on GitHub (Jun 24, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5534 ### What are you trying to do? I am trying to understand how the new `Share address strategy` setting is supposed to work and how it relates to the old `externalProxy` behavior. In previous versions, `externalProxy` was used to define the address that should be written into exported share links, QR codes, and subscription output when the panel was behind a router / reverse proxy / NAT. In the current UI, there is a new setting here: Inbounds -> Edit inbound -> Basics -> Share address strategy The description says: Controls which address is written into exported share links, QR codes, and subscription output. By default, it is set to: Inbound listen This looks like it may be a replacement for the old `externalProxy` setting. However, even when `Share address strategy` is set to `Inbound listen`, the config still contains: "externalProxy": [ { "forceTls": "same", "dest": "XXX.XXX", "port": 443, "remark": "" } ] When I change `Share address strategy` to `Custom` and set a custom address, I do not see any change in the `externalProxy` config. So I am not sure what the expected relationship is between these settings. Is `Share address strategy` supposed to replace `externalProxy`, or is it a separate setting? Should changing `Share address strategy` to `Custom` update `externalProxy`, or is the custom address stored somewhere else? Also, there is now a `Hosts` tab, and it is not clear what it is intended for. The content of the `Hosts` tab looks like it corresponds to the existing `externalProxy` config. At least visually, it seems to contain the same type of data as `externalProxy`. So I would like to clarify the intended model: externalProxy Hosts tab Inbounds -> Edit inbound -> Basics -> Share address strategy Are these three parts connected? If yes, what is the expected workflow for a panel behind a router / reverse proxy where exported share links, QR codes, and subscriptions should use a public external address instead of the inbound listen address? For example, if the inbound listens locally or behind NAT, but users should connect to: example.com:443 where should this address be configured now? Should it be configured in: Hosts or: Inbounds -> Edit inbound -> Basics -> Share address strategy -> Custom or: externalProxy or some combination of them? The current UI is confusing because `Share address strategy` sounds like the setting that controls exported share links, but changing it to `Custom` does not appear to update the visible `externalProxy` config. At the same time, the `Hosts` tab looks like it may be the new UI for `externalProxy`, but this is not obvious from the UI. ### What have you already tried? _No response_ ### 3x-ui version 3.4.0 ### How did you install 3x-ui? install.sh script ### Operating system Debian 12 ### Screenshots or config snippets _No response_ ### Before submitting - [x] I read the [Wiki](https://github.com/MHSanaei/3x-ui/wiki) and searched [existing issues](../issues?q=is%3Aissue). - [x] This is a usage question, not a bug report. - [x] This question is written in English.
bsakaguchi 2026-10-31 20:35:30 +07:00
  • closed this issue
  • added the
    question
    label
Author
Owner

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

These three mechanisms are related but serve distinct roles. Here is what the source code confirms.


1. externalProxy (legacy)

externalProxy is an array stored inside an inbound's streamSettings JSON blob. In older versions it was the only way to tell the subscription engine to advertise a different address/port/TLS to connecting clients. The field is still parsed by the subscription service (internal/sub/service.go) and still works — but only when no Hosts are defined for that inbound (see point 2). The field is no longer editable in the inbound editor; a comment in frontend/src/pages/inbounds/form/InboundFormModal.tsx (line 806) reads: "The legacy externalProxy section is replaced by the Hosts page; the field is still parsed/rendered for backward compatibility but is no longer editable here."

2. Hosts (the replacement for externalProxy)

The Hosts page (frontend/src/pages/hosts/) manages rows in a separate hosts database table. Each row belongs to a specific inbound and defines one external endpoint — address, port, TLS/security, SNI, fingerprint, path, etc.

When the subscription service builds links for an inbound, it first calls hostEndpoints() (internal/sub/host_sub.go:19). If any enabled Hosts exist for that inbound, the service uses those exclusively and the externalProxy array in streamSettings is bypassed entirely:

// internal/sub/service.go:207-216
hostEps := s.hostEndpoints(inbound, "raw")
for _, client := range clients {
    if len(hostEps) > 0 {
        link = s.linkFromHosts(inbound, client, hostEps)
    } else {
        link = s.GetLink(inbound, client.Email)  // falls back to externalProxy path
    }
}

The hostToExternalProxyMap() function (internal/sub/host_sub.go:45) translates each Host into an externalProxy-shaped map that the existing per-format renderers consume. One share link is generated per enabled Host per client.

Why you still see externalProxy in the JSON after upgrading: The database migration (seedHostsFromExternalProxy in internal/database/db.go:164) was intentionally additive. It read every inbound's streamSettings, created a Host row for each externalProxy entry, and left the original externalProxy array untouched. The two now coexist in storage, but at runtime only the Hosts table entries are used (because hostEndpoints() returns non-nil and short-circuits the legacy path).

3. Share address strategy (shareAddrStrategy)

This is a column on the inbounds table (internal/database/model/model.go:69-70). It controls the address resolved by resolveInboundAddress() (internal/sub/service.go:939) — this is the base/fallback address used when:

  • generating a single share link for an inbound that has no Hosts, or
  • filling in the destination for a Host row that has an empty Address field (a "relative" host that inherits the inbound's address but overrides other settings).
// internal/sub/service.go:951-957
candidates := []string{nodeAddr, listenAddr}   // default: "node"
switch inbound.ShareAddrStrategy {
case "listen":
    candidates = []string{listenAddr, nodeAddr}
case "custom":
    candidates = []string{strings.TrimSpace(inbound.ShareAddr), nodeAddr, listenAddr}
}

Changing shareAddrStrategy to custom does not modify externalProxy because they are independent mechanisms. shareAddrStrategy is a lightweight override on the inbound row itself; externalProxy is part of the raw stream JSON.


Recommended workflow for NAT / reverse-proxy (inbound on LAN, users connect to example.com:443)

There are two approaches:

A — Single endpoint, no CDN (simplest): If clients connect to exactly one address, set Share address strategy to Custom and Share addr to example.com on the inbound. The subscription service will use example.com as the host in every generated link, combined with the inbound's configured port.

B — One or more external endpoints (Hosts approach, recommended for multi-CDN or when you want per-endpoint TLS/SNI control): Go to the Hosts page, create a Host for the inbound with Address = example.com, Port = 443, and the appropriate Security / SNI values. Each enabled Host generates one share link per client. You can create multiple Hosts for the same inbound to produce multiple links (CDN, clean-IP, direct, etc.).

If you already have externalProxy entries that were migrated, the corresponding Host rows were created automatically during upgrade. You can manage them from the Hosts page. The stale externalProxy array remaining in the JSON has no effect on link generation as long as at least one enabled Host exists for that inbound.


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

<!-- gh-comment-id:4788546319 --> @github-actions[bot] commented on GitHub (Jun 24, 2026): These three mechanisms are related but serve distinct roles. Here is what the source code confirms. --- **1. `externalProxy` (legacy)** `externalProxy` is an array stored inside an inbound's `streamSettings` JSON blob. In older versions it was the only way to tell the subscription engine to advertise a different address/port/TLS to connecting clients. The field is still parsed by the subscription service (`internal/sub/service.go`) and still works — but only when no Hosts are defined for that inbound (see point 2). The field is no longer editable in the inbound editor; a comment in `frontend/src/pages/inbounds/form/InboundFormModal.tsx` (line 806) reads: _"The legacy externalProxy section is replaced by the Hosts page; the field is still parsed/rendered for backward compatibility but is no longer editable here."_ **2. Hosts (the replacement for `externalProxy`)** The Hosts page (`frontend/src/pages/hosts/`) manages rows in a separate `hosts` database table. Each row belongs to a specific inbound and defines one external endpoint — address, port, TLS/security, SNI, fingerprint, path, etc. When the subscription service builds links for an inbound, it first calls `hostEndpoints()` (`internal/sub/host_sub.go:19`). If any enabled Hosts exist for that inbound, the service uses those exclusively and the `externalProxy` array in `streamSettings` is bypassed entirely: ```go // internal/sub/service.go:207-216 hostEps := s.hostEndpoints(inbound, "raw") for _, client := range clients { if len(hostEps) > 0 { link = s.linkFromHosts(inbound, client, hostEps) } else { link = s.GetLink(inbound, client.Email) // falls back to externalProxy path } } ``` The `hostToExternalProxyMap()` function (`internal/sub/host_sub.go:45`) translates each Host into an externalProxy-shaped map that the existing per-format renderers consume. One share link is generated per enabled Host per client. **Why you still see `externalProxy` in the JSON after upgrading:** The database migration (`seedHostsFromExternalProxy` in `internal/database/db.go:164`) was intentionally additive. It read every inbound's `streamSettings`, created a Host row for each `externalProxy` entry, and left the original `externalProxy` array untouched. The two now coexist in storage, but at runtime only the Hosts table entries are used (because `hostEndpoints()` returns non-nil and short-circuits the legacy path). **3. Share address strategy (`shareAddrStrategy`)** This is a column on the `inbounds` table (`internal/database/model/model.go:69-70`). It controls the address resolved by `resolveInboundAddress()` (`internal/sub/service.go:939`) — this is the **base/fallback address** used when: - generating a single share link for an inbound that has no Hosts, or - filling in the destination for a Host row that has an empty `Address` field (a "relative" host that inherits the inbound's address but overrides other settings). ```go // internal/sub/service.go:951-957 candidates := []string{nodeAddr, listenAddr} // default: "node" switch inbound.ShareAddrStrategy { case "listen": candidates = []string{listenAddr, nodeAddr} case "custom": candidates = []string{strings.TrimSpace(inbound.ShareAddr), nodeAddr, listenAddr} } ``` Changing `shareAddrStrategy` to `custom` does **not** modify `externalProxy` because they are independent mechanisms. `shareAddrStrategy` is a lightweight override on the inbound row itself; `externalProxy` is part of the raw stream JSON. --- **Recommended workflow for NAT / reverse-proxy (inbound on LAN, users connect to `example.com:443`)** There are two approaches: **A — Single endpoint, no CDN (simplest):** If clients connect to exactly one address, set `Share address strategy` to `Custom` and `Share addr` to `example.com` on the inbound. The subscription service will use `example.com` as the host in every generated link, combined with the inbound's configured port. **B — One or more external endpoints (Hosts approach, recommended for multi-CDN or when you want per-endpoint TLS/SNI control):** Go to the Hosts page, create a Host for the inbound with `Address = example.com`, `Port = 443`, and the appropriate `Security` / `SNI` values. Each enabled Host generates one share link per client. You can create multiple Hosts for the same inbound to produce multiple links (CDN, clean-IP, direct, etc.). If you already have `externalProxy` entries that were migrated, the corresponding Host rows were created automatically during upgrade. You can manage them from the Hosts page. The stale `externalProxy` array remaining in the JSON has no effect on link generation as long as at least one enabled Host exists for that inbound. --- *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#3863
No description provided.