Untrusted Domain/Redirected to localhost/127.0.0.1/local IP


#1

Problem:
When accessing ownCloud, after logging in, you’re being redirected to localhost or 127.0.0.1; or to an IP address from your local network, when you’re actually accessing ownCloud from externally.
Or you are being told that “You are accessing the server from an untrusted domain. Please contact your administrator”.

Answer:
ownCloud 6.0.x introduced a trusted_domain setting.
This setting needs to contain the host name or IP address that ownCloud is accessed under (the server’s domain / host name or IP address, not those of clients!)

The URL used for setting up the ownCloud server for the first time is stored in this configuration entry; and only accesses from URLs contained in that setting are allowed; all accesses from different URLs will be redirected to the first URL mentioned in those settings.

So to allow access from a specific URL, add this URL to the configuration entry.

Example 1:

You want to allow access your ownCloud via foo.example.com (i.e., users will enter

https://foo.example.com/path/to/owncloud

in the browser or in their clients to get access to the ownCloud installation).

Then your trusted domain should look like this:

'trusted_domains' => array('foo.example.com'),

Example 2:
Let’s say that in addition to the domain from example 1, you want to allow your users to access ownCloud via the domain bar.example.com, and let’s say also via foo2.example.com on a non-standard port 12321; where foo.example.com should be the the primary URL to be used; then make your trusted_domain entry look like this:

'trusted_domains' => array (
'foo.example.com', 
'bar.example.com', 
'foo2.example.com:12321'
),

Also see the documentation: http://doc.owncloud.org/server/6.0/admin_manual/installation/installation_source.html#note

Starting with OC 7.0.2 a “Trusted Domain Wizard” was introduced which makes this process easier:


#2