Apache Reverse Proxy - sites-available/000-default.conf vs sites-available/nextcloud.conf

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5): 22.1.1
Operating system and version (eg, Ubuntu 20.04): 20.04 LTS
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.25
PHP version (eg, 7.4): 7.4

Hey all,

I followed this tutorial https://www.linuxbabe.com/ubuntu/install-nextcloud-ubuntu-20-04-apache-lamp-stack and have Nextcloud running with SSL.
I would like to setup Apache Reverse Proxy so I can in additon to Nextcloud access I would be able to access other services TrueNAS, FreePBX etc.
What I got stuck is above tutorial creates new /etc/apache2/sites-available/nextcloud.conf and others tutorials for Reverse Proxy Apache Reverse Proxy Configuration: Accessing Applications by Subdomains - Tech Guides point to
/etc/apache2/sites-available/000-default.conf ?

Any help would be apprecited!

Hi @JohnyBeGood

default.conf is, as the name suggests, the default VirtualHost, which in most distributions points to /var/www/html and serves the Apache default page. When you install Nextcloud or any other service, you can either modify the default.conf to your needs or you can create a new VirtualHost respective a new.conf file, enable it with a2ensite new.conf and use that to serve the respective service. If you don’t use the default.conf, you can disable it with a2dissite default.conf.

About the question when you need a reverse proxy and when you do not:

If Nextcloud is already running on this server, you don’t need to change anything, you can just create additional VirtualHosts by adding more.conf files for the additional services and enable them with a2ensite name.conf. They can contain a reverse proxy configuration, if they for example point to another server or to a Docker container that already has it’s own web server running. Or they can contain a “normal” configuration if they point to services (most likley running on the same server) without their own web server. You can of course also install Apache on a third server, which then acts as a reverse proxy for all of your services and servers.

Thank you for taking the time to explain, now I have a better understanding.

From what I’ve read hear if I wanted to change default port 80/443 that Nextcloud is listening I would need to change that on Apache. There’s no way to have Apache stay on 80/443 and Nextcloud on ie. 8080/4434?
So far, I was able to make Reverse Proxy for Syntcthing which forwards to 8384. That is just an example, but I’m thinking down the road that I will have more services that want to run on 80/443 and there be a conflict.

To be able to run multiple Web Services / VirtualHosts on one public IP address and / or on a single server, it is best to register a domain name. You can then use different subdomains for each service like nextcloud.yourdomain.com, syncthing.yourdomain.com, otherservice.yourdomain.com etc. and define them with the ServerName directive in the respective .conf file.

Examples:

VirtualHost for Nextcloud:

<VirtualHost *:443>
    DocumentRoot "var/www/nextcloud"
    ServerName nextcloud.yourdomain.com

    # Other directives here

</VirtualHost>

VirtualHost for Synchthing:

<VirtualHost *:443>
    ServerName syncthing.yourdomain.com

    ProxyPass /syncthing/ http://localhost:8384/

<Location /syncthing/>
    ProxyPassReverse http://localhost:8384/
    Require all granted
</Location>
 
    # Other directives here

</VirtualHost>
1 Like

Thank you! Already have a domain. This worked like a charm!

1 Like