go-gitea/gitea

Multiple ROOT_URL syntax/possible?

Closed this issue · 5 comments

Is it possible to set multiple root urls? My use case involves multiple domains reverse proxied to the same backend vm.

The docs give this:
%(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/

The ()s part of that implies to me that there is a way for mutiple options. I cannot, however, figure out the syntax.
Tried: space separated, comma separated, both of those within round, square and curly brackets

Most attempts get 505 bad gateway.
ROOT_URL = https://(domain1/gitea,domain2/gitea)/
causes both domains to load text only. (Both domains load properly with just one domain in the root url but things like oauth2 logins won't work).

Edit:
ROOT_URL = https://(domain1,domain2)/gitea/
is the best so far, with both domains rendering properly. However, github login doesn't work for either. With ROOT_URL = https://domain1/gitea/ both domains render properly and github login works with domain1.

I think the success of the
ROOT_URL = https://(domain1,domain2)/gitea/
syntax with regards to page rendering proves that multiple ROOT_URLs is possible.

The key question now is whether this will work with the correct syntax or whether the ROOT_URL implementation actually has a bug.

lunny commented

Multiple ROOT_URL is not supported currently I think.

I would like to share a use case (which is not so rare for me) to ensure this ticket does not fall into oblivion:

When working for larger clients (means: companies with many employees), the issue section (only this one) should be available for the employees to report problems. So far no problem, you can set the user permissions to limit access to issues.

The clients want the issue tracker to be available under the client's domain (e.g. gitea.company.com), but it actually operates under my own domain (e.g. gitea.mydomain.com). The reasons for this customer request are numerous, but essentially it is about brand identity and avoiding irritation among employees who have followed a link on the intranet and end up on the domain of a company they do not know.

A similar situation: the company hires design agency A, which then hires agency B for the technical development. Agency B should not be mentioned to the client, which is why the issue tracker should be provided under a different domain.

Making Gitea available under multiple domains is possible, at least with regard to the issue tracker, if a few small things are changed:

In the application, some links contain the domain, others (most) do not. In the list of issues, those are linked with domain, which is not necessary in this case and probably easy to change.

The emails sent by Gitea contain links to the web interface and these necessarily include the domain. In this case, it would be good if the URL is based on the domain currently used in the browser (e.g. gitea.company.com instead of gitea.mydomain.com). This is not perfect, because if a developer accesses via the main URL and initiates an action that sends a mail, the customer would receive a mail with the wrong domain. Therefore, it would be even better if the desired domain could be entered in the repository settings and this domain would then always be used for mails.

Another option would be to have a variable with the current domain name and a search-and-replace function available in the templates. Then one could do something like this pseudo code in the mail templates:

{{ if ne .CurrentDomain AppDomain }}
      {{SearchAndReplace .Link AppDomain .CurrentDomain}}
{{ end }}

Root case is #19345

@teotikalki s solution serves the page on both URLs but displays an error message about a wrong ROOT_URL on both domains.