[GH-ISSUE #6747] [Question]: Multiple domains for the subscription link, each with its own certificate #4495

Open
opened 2026-10-31 20:40:03 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @Matin4359 on GitHub (Oct 5, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6747

What are you trying to do?

Hi, as title says, possible or very hard?

What have you already tried?

No response

3x-ui version

3.90

How did you install 3x-ui?

install.sh script

Operating system

No response

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 @Matin4359 on GitHub (Oct 5, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6747 ### What are you trying to do? Hi, as title says, possible or very hard? ### What have you already tried? _No response_ ### 3x-ui version 3.90 ### How did you install 3x-ui? install.sh script ### Operating system _No response_ ### 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.
Author
Owner

@github-actions[bot] commented on GitHub (Oct 5, 2026):

The built-in subscription server cannot do this by itself: it accepts one certificate/key pair and one domain. You can still get it working in either of these ways:

  1. Easiest: one certificate that covers every domain. A SAN or wildcard certificate (one cert listing sub1.example.com, sub2.example.org, …) works with the built-in server as it is.
  2. Separate certificates per domain: put a reverse proxy in front. Nginx or Caddy picks the right certificate for each domain (by SNI) and forwards the traffic to the subscription server.

Why the built-in server takes only one certificate

  • internal/sub/sub.go:426-433 loads one pair from the subCertFile / subKeyFile settings:
    cert, err := tls.LoadX509KeyPair(certFile, keyFile)
    ...
    Certificates: []tls.Certificate{cert},
    
  • subDomain holds a single host. When it is set, DomainValidatorMiddleware (internal/web/middleware/domainValidator.go:24) returns 403 for any other Host: if host != domain {. When it is empty, no check runs and every domain pointed at the server is accepted (internal/sub/sub.go:63).

Reverse-proxy setup

  1. In panel settings → Subscription, leave subDomain empty, clear subCertFile / subKeyFile, and set subListen to 127.0.0.1 so the server only answers the proxy over plain HTTP.
  2. In Nginx, add one server { ... } block per domain, each with its own ssl_certificate / ssl_certificate_key and proxy_pass http://127.0.0.1:<subPort>;. In Caddy, add one site block per domain and certificates are handled automatically.
  3. Point each domain's DNS at the server. Clients can then use https://<any-of-your-domains>/<subPath>/<subId>, because the path and sub ID are the same on every domain.

The panel shows a single link for each client. If subURI is empty, that link is built from the address you opened the panel with (BuildSubURIBase, internal/web/service/setting.go:1903). If you set subURI, it always shows that one base. To hand out a link on another domain, replace the domain part of the link.

Docs: Reverse proxy and Subscription settings.

If you need native support for several certificates in the built-in subscription server, that would be a feature request. Please open it with the bug/feature form.

I changed the title from "[Question]: [Question]: using multi domain name for subscription link with with independent certs." to remove the repeated prefix.

Verdict: Not a bug (expected behaviour)

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

<!-- gh-comment-id:6003048702 --> @github-actions[bot] commented on GitHub (Oct 5, 2026): The built-in subscription server cannot do this by itself: it accepts one certificate/key pair and one domain. You can still get it working in either of these ways: 1. **Easiest: one certificate that covers every domain.** A SAN or wildcard certificate (one cert listing `sub1.example.com`, `sub2.example.org`, …) works with the built-in server as it is. 2. **Separate certificates per domain: put a reverse proxy in front.** Nginx or Caddy picks the right certificate for each domain (by SNI) and forwards the traffic to the subscription server. **Why the built-in server takes only one certificate** - `internal/sub/sub.go:426-433` loads one pair from the `subCertFile` / `subKeyFile` settings: ```go cert, err := tls.LoadX509KeyPair(certFile, keyFile) ... Certificates: []tls.Certificate{cert}, ``` - `subDomain` holds a single host. When it is set, `DomainValidatorMiddleware` (`internal/web/middleware/domainValidator.go:24`) returns `403` for any other Host: `if host != domain {`. When it is empty, no check runs and every domain pointed at the server is accepted (`internal/sub/sub.go:63`). **Reverse-proxy setup** 1. In panel settings → Subscription, leave `subDomain` **empty**, clear `subCertFile` / `subKeyFile`, and set `subListen` to `127.0.0.1` so the server only answers the proxy over plain HTTP. 2. In Nginx, add one `server { ... }` block per domain, each with its own `ssl_certificate` / `ssl_certificate_key` and `proxy_pass http://127.0.0.1:<subPort>;`. In Caddy, add one site block per domain and certificates are handled automatically. 3. Point each domain's DNS at the server. Clients can then use `https://<any-of-your-domains>/<subPath>/<subId>`, because the path and sub ID are the same on every domain. The panel shows a single link for each client. If `subURI` is empty, that link is built from the address you opened the panel with (`BuildSubURIBase`, `internal/web/service/setting.go:1903`). If you set `subURI`, it always shows that one base. To hand out a link on another domain, replace the domain part of the link. Docs: [Reverse proxy](https://github.com/MHSanaei/3x-ui/blob/main/docs/content/docs/en/operations/reverse-proxy.mdx) and [Subscription settings](https://github.com/MHSanaei/3x-ui/blob/main/docs/content/docs/en/config/subscription.mdx). If you need native support for several certificates in the built-in subscription server, that would be a feature request. Please open it with the bug/feature form. I changed the title from "[Question]: [Question]: using multi domain name for subscription link with with independent certs." to remove the repeated prefix. Verdict: Not a bug (expected behaviour) *This reply was generated automatically; a maintainer may follow up.* <!-- claude-issue:analyst -->
Author
Owner

@Matin4359 commented on GitHub (Oct 5, 2026):

Does the developer intend to provide this functionality in the form of a graphical interface along with a suitable web server?

<!-- gh-comment-id:6004020850 --> @Matin4359 commented on GitHub (Oct 5, 2026): Does the developer intend to provide this functionality in the form of a graphical interface along with a suitable web server?
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#4495
No description provided.