[GH-ISSUE #5251] [Feature]: Allow overriding the port in addition to the address under the 'Share address strategy' option #3678

Closed
opened 2026-10-31 20:34:10 +07:00 by bsakaguchi · 2 comments
Owner

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

I use Nginx on port 443 as a reverse proxy to route traffic to multiple inbounds for different protocols. Since the inbounds use different local ports, the generated sub/export links end up with the wrong ports.

Describe the solution you'd like

I'd be very grateful if we could override the port as well as the address in the subscription/export settings. Another option would be supporting multiple inbounds on a single port in 3x-ui, but I assume that's more difficult to implement.

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?

Subscription (share links / Clash / JSON)

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 @ex-lain on GitHub (Jun 13, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5251 ### Is your feature request related to a problem? I use Nginx on port 443 as a reverse proxy to route traffic to multiple inbounds for different protocols. Since the inbounds use different local ports, the generated sub/export links end up with the wrong ports. ### Describe the solution you'd like I'd be very grateful if we could override the port as well as the address in the subscription/export settings. Another option would be supporting multiple inbounds on a single port in 3x-ui, but I assume that's more difficult to implement. ### 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? Subscription (share links / Clash / JSON) ### Are you willing to help? - [ ] 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.
bsakaguchi 2026-10-31 20:34:10 +07:00
Author
Owner

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

The current "Share address strategy" feature (confirmed in internal/database/model/model.go and internal/web/service/inbound.go) supports three modes — node, listen, and custom — for overriding the host/address in subscription links, but there is no corresponding field to override the port. In every protocol link generator in internal/sub/service.go (lines 427, 513, 571, 674, 790, etc.) the port is always taken directly from inbound.Port without any override path. So the gap you have identified is real and not currently supported via the share address strategy.

Existing partial workaround — External Proxies

There is an existing mechanism that does support both host and port override: the External Proxy entries in an inbound's stream settings. Each external proxy entry has a dest (host) and port field; when one or more entries are configured, the subscription service generates a separate share link per entry (using those host/port values) rather than the inbound's own listen address and port. This is implemented in internal/sub/service.go:buildExternalProxyURLLinks (line 1472) and is called for VMess, VLESS, Trojan, Shadowsocks, and Hysteria2.

The trade-off with external proxies is that they generate additional links alongside (or instead of) the primary inbound link, and they carry extra TLS/SNI parameters intended for CDN fronting scenarios. For a straightforward Nginx-on-443 reverse proxy case — where you simply want the single generated link to advertise port 443 instead of the inbound's local port — this is more complex than needed, and it may not produce the clean output you want for all client types.

What this feature request would add

A sharePort field (analogous to shareAddr) on the inbound record, respected by the three existing strategy modes, would be the natural extension. A PR implementing this would need to touch:

  • internal/database/model/model.go — add the field and a migration
  • internal/web/service/inbound.go — validate/normalize the value
  • internal/sub/service.go — introduce a resolveInboundPort helper (parallel to resolveInboundAddress) and wire it into each protocol link generator
  • frontend/src/ — expose the field in the inbound settings form

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

<!-- gh-comment-id:4697318572 --> @github-actions[bot] commented on GitHub (Jun 13, 2026): The current \"Share address strategy\" feature (confirmed in `internal/database/model/model.go` and `internal/web/service/inbound.go`) supports three modes — `node`, `listen`, and `custom` — for overriding the **host/address** in subscription links, but there is no corresponding field to override the **port**. In every protocol link generator in `internal/sub/service.go` (lines 427, 513, 571, 674, 790, etc.) the port is always taken directly from `inbound.Port` without any override path. So the gap you have identified is real and not currently supported via the share address strategy. **Existing partial workaround — External Proxies** There is an existing mechanism that does support both host and port override: the **External Proxy** entries in an inbound's stream settings. Each external proxy entry has a `dest` (host) and `port` field; when one or more entries are configured, the subscription service generates a separate share link per entry (using those host/port values) rather than the inbound's own listen address and port. This is implemented in `internal/sub/service.go:buildExternalProxyURLLinks` (line 1472) and is called for VMess, VLESS, Trojan, Shadowsocks, and Hysteria2. The trade-off with external proxies is that they generate **additional** links alongside (or instead of) the primary inbound link, and they carry extra TLS/SNI parameters intended for CDN fronting scenarios. For a straightforward Nginx-on-443 reverse proxy case — where you simply want the single generated link to advertise port 443 instead of the inbound's local port — this is more complex than needed, and it may not produce the clean output you want for all client types. **What this feature request would add** A `sharePort` field (analogous to `shareAddr`) on the inbound record, respected by the three existing strategy modes, would be the natural extension. A PR implementing this would need to touch: - `internal/database/model/model.go` — add the field and a migration - `internal/web/service/inbound.go` — validate/normalize the value - `internal/sub/service.go` — introduce a `resolveInboundPort` helper (parallel to `resolveInboundAddress`) and wire it into each protocol link generator - `frontend/src/` — expose the field in the inbound settings form _This reply was generated automatically; a maintainer may follow up._
Author
Owner

@MHSanaei commented on GitHub (Jul 3, 2026):

Since this issue was opened, the panel gained a Hosts feature (PR #5409) that covers this exact use case. Open the Hosts page from the panel sidebar and add a host entry for each inbound behind your reverse proxy: leave the address blank to inherit the inbound's share address, and set the port to 443 (a port of 0 inherits the inbound's own port).

When an inbound has host entries, the subscription output (raw, JSON, and Clash) emits links using the host's address and port instead of the inbound's local listen port — and hosts also support per-entry SNI, path, and host-header overrides for reverse-proxy setups.

Closing as available in the current release — please comment if your scenario still isn't covered.

<!-- gh-comment-id:4873798769 --> @MHSanaei commented on GitHub (Jul 3, 2026): Since this issue was opened, the panel gained a **Hosts** feature (PR #5409) that covers this exact use case. Open the Hosts page from the panel sidebar and add a host entry for each inbound behind your reverse proxy: leave the address blank to inherit the inbound's share address, and set the port to 443 (a port of 0 inherits the inbound's own port). When an inbound has host entries, the subscription output (raw, JSON, and Clash) emits links using the host's address and port instead of the inbound's local listen port — and hosts also support per-entry SNI, path, and host-header overrides for reverse-proxy setups. Closing as available in the current release — please comment if your scenario still isn't covered.
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#3678
No description provided.