Is there a way to change the domain used in file sharing URLs?
The domain I use to access Nextcloud is pretty long, so I set up a shorter one that redirects to it. When sharing via link, I can copy and paste the generated URL into a text editor and replace the long domain with the short one, but it’d be a lot more convenient if the generated URL did that.
I tried setting “overwritehost” in the config, but that broke Nextcloud when I accessed it from a different domain.
@Bugsbane If I add a reply to my own post, will it show up in the new/recent threads again? I feel like after a week, it’s not going to pop up for anyone anymore…
I think it should. That said, when you’re talking about URL rewrites it can get complicated as it dependsa lot on the setup of your particular server, so to be honest, it’s a bit ofa tricky question to answer. You can try bumping it (posting to your own thread, to raise it again). Just be aware that it’s considered bad netiquette to bump more than once a week, or to do it repeatedly.
and configure your Webserver with e.g. a new VirtualHost with other domain for Apache2.
Pattern is: https://oldLongDomainName.example.org/index.php/s/fDC581z1r46fxaf, where
https://oldLongDomainName.example.org/ is totally webserver controlled and independent of NC installation.
.../index.php/s/fDC581z1r46fxaf or could be .../nextcloud/index.php/s/fDC581z1r46fxaf is what is shared URL and bounded to NC Application, fDC581z1r46fxafis shared secret URL. This part will remain the same even if you change domain or use 2 different domains, or something else.
Thank you for the reply! Adding my regular domains to the trusted_domains list and setting overwritehost to my short domain has almost solved my problem. Everything seems to be working, with the notable (and intended) difference that generated sharing links now use my short domain, despite the page being accessed by my longer domain.
However, when I view the javascript console in my browser’s page inspector, I see 12+ errors that resolving a URL failed because of too many HTTP redirects, listing the URL for the main page on my longer domain. It seems like there’s some script redirecting some request to the short domain and getting caught in an infinite loop that browsers (hopefully) eventually kill. Everything seems to work despite this, but I wonder if there’s any fix for that.
I think this is already your web server setup “issue” (I would say feature). For web server (e.g. Apache2) you have at least 2 VirtuaHost - one for each domain and if you set Apache2 settings correct cookies will not be shared between domains - for web server those are 2 independent projects/Appalications. Just test it:
login to NC via Domain1
Open NC via Domain2 → you will be prompted to login page
Basically if you will login in both domains and repeat you test you should not see any errors in console… But I’m not sure
NC is only accessed through the longer domain; the shorter domain is completely web-server-controlled, and just redirects to the longer domain with the same path and arguments.
You’re right that using multiple domains causes its own issues (I had to modify the content-security-policy header, for example), but I think the issue in this case is a redirect loop.