0

I have a newly setup vps at mydomain.com:

$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.5 LTS Release: 20.04 Codename: focal $ 

and the administrators installed nextcloud for me. I point my nextcloud clients to work.mydomain.com and it works great. I also want to set up a webserver for www.mydomain.com. Currently, when I point a webbrowser to www.mydomain.com, I get a nextcloud-styled page that says "Access through untrusted domain, Please contact your administrator." This suggests that a webserver is running. Indeed:

$ sudo netstat -tnlp | grep 80 tcp6 0 0 :::80 :::* LISTEN 844835/httpd $ 

and apache2 is not installed. If I install it, I get:

$ service apache2 status ● apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor prese> Active: failed (Result: exit-code) since Tue 2023-01-31 17:08:54 CET; 1 we> Docs: https://httpd.apache.org/docs/2.4/ :/$ 

So, it looks to me like nextcloud's webserver is handling www.mydomain.com. There are only 2 references to the domain in nextcloud's config.php:

 ... 'trusted_domains' => array ( 0 => 'work.mydomain.com', ), 'datadirectory' => '/var/snap/nextcloud/common/nextcloud/data', 'dbtype' => 'mysql', 'version' => '25.0.2.3', 'overwrite.cli.url' => 'https://work.mydomain.com', ... 

So I don't see how calls to www.mydomain.com are being served. How do I serve my own pages to www.mydomain.com?

1 Answer 1

2

You are trying to run a webserver, while Nextcloud is also running on the same server, both at port 80 (or 443 for secure/TLS connections).

By default, if you type in an IP to your browser, it redirects to port 80 (or 443). Here, both www.mydomain.com and work.mydomain.com are redirecting to port 80 (or 443) of your server, but only the work subdomain is authorized to reach Nextcloud.

The reason Apache failed to start was because it is configured by default to handle requests made to port 80 and 443, and those ports are being used by Nextcloud already.

You should use a reverse proxy configuration to to serve both Nextcloud and the website. Apache itself can double as a reverse proxy and webserver. Basically, you'll have Apache intercept the requests to port 80 and 443, and based on the format of the URL, if it is work.mydomain.com, you redirect it to Nextcloud, and if it is www.mydomain.com, you redirect it to the website.

This is done using the VirtualHost section. An example is available here.

1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center. Commented Jul 8, 2023 at 0:02

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.