Can I have two domains pointing towards the same IP address without redirect?

It’s possible for me, although hacky. Don’t blame me if it breaks something for you. A site specific (non-generic) plugin was created:
https://github.com/mig5/discourse-whonix-onion-host-support

Appreciate comments.

That plugin does “most” (can’t quantify) of the work. For the rest I am using nginx subs_filter.

Though, CSP on secondary domain is getting into the way.


My use case: providing a secondary .onion domain. Quote

Onion Location

Website publishers now can advertise their onion service to Tor users by adding an HTTP header. When visiting a website that has both an .onion address and Onion Location enabled via Tor Browser, users will be prompted about the onion service version of the site and will be asked to opt-in to upgrade to the onion service on their first use.

If you are a developer, learn how to enable onion-location in your onion service.

Another cool use case is alt-svc (related to cloudflare onion).

.onion is also useful for non-location hidden, public servers. It’s an alternative means of end-to-end (or Tor to Tor) encryption that doesn’t rely on SSL/TLS certificate authorities. Onions can also be made fast using server side using HiddenServiceNonAnonymousMode 1, HiddenServiceSingleHopMode 1 and client side using Tor2Web mode (single hop).

Good point but not worried about this. The secondary domain name (in my case .onion) could use HTTP header X-Robots-Tag: noindex.

Related:
Forcing hostname has broken support for Onion Services

Potential duplicate:
How to add a second domain name?