Nextcloud inside virtualhost

During NethServer convention, you’ve asked to allow accessing web applications using a custom virtual host.

I just found this excellent solution by @enzoturri:

I also baked a possible solution that can be implemented in various web application (or at least I hope so).
This is also specific for Nextcloud for now.

  1. Create a template-custom dir:

     mkdir -p /etc/e-smith/templates-custom/etc/httpd/conf.d/zz_nextcloud.conf
  2. Inside the new directory, create a file named 10base, cut & past inside the content from:

  3. Set your virtual host name:

     config setprop nextcloud TrustedDomains
     config setprop nextcloud VirtualHost
     expand-template /etc/httpd/conf.d/zz_nextcloud.conf
     signal-event nethserver-nextcloud-update

Do you think this is a general requirements for any other web application? /cc @syntaxerrormmm @fuso


It really depends on how you intend to offer the services. I do think that “” could be simpler and clearer than “”, also because you are now bound to use “nextcloud” as the directory name and usually non-technical people don’t remember the name of the product; “cloud” is a much more simpler word to remember, to them.

Obviously, instead of customizing each web application path before installing it, probably a simpler way to implement some customization is to use vhosts, hence the request :wink: And probably applying the same logic to other web applications could be a winning point (Webtop is a simple application name, but it doesn’t work so well as, for example, “webmail”).

Your solution seems fine to me, but I don’t have the time to test it today. Will do some tests in the next few days and let you know. Sorry.

Hello @giacomo,

I tested it now and it works like a charm. :clap:

1 Like

An easier way, the way I do it is create /etc/httpd/sites-enabled and /etc/httpd/sites-available in the httpd folder, that way you have full control over the vhost. I have nextcloud along with a few other servers running off of a freenas server and this will allow letsencrypt certs for any vhost I desire, pretty simply. Feel free to copy and paste this, replace the internal ip’s with the ip of the hosted server and the addresses with “” or anything you wish.

From your preferred SSH cli tool:

  1. sudo nano /etc/httpd/conf/httpd.conf (I LOVE nano)

  2. IncludeOptional sites-enabled/*.conf (Place this in httpd.conf, it tells the system to use traditional apache location for vhosts)

  3. Copy the vhost from below and copy into in the sites-available folder (example: I used for a nextcloud install)

  4. sudo ln -s /etc/httpd/sites-available/ /etc/httpd/sites-enabled/

  5. This is all assuming you created some vhosts in the GUI of nethserver, so you create under vhosts, nextcloud could be Anyways, under vhosts select require ssl, not required but if youre using letsencrypt certs why not.

  6. Oops forgot the important bit “sudo apachectl restart” will restart apache and load the conf files you created. This can be replicated as many times as you want, throw a different ip, different subdomain and restart apache and youre all set.

<VirtualHost *:80>
    RewriteEngine on
    RewriteCond %{HTTPS} !on
    RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301]
    ProxyPreserveHost On
    ProxyPass /
    ProxyPassReverse /

<VirtualHost *:443>
   # RewriteEngine on
   # RewriteCond %{HTTPS} !on
   # RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301]
   # RewriteRule ^ https://%{}%{REQUEST_URI} [END,QSA,R=permanent]
    ProxyPreserveHost On
    ProxyPass /
    ProxyPassReverse /

Edit: Forgot restart apache :blush:
Edit2: Apache will error out if any conf file has bad code in it but copy and paste this and you should be good. This should be in the vhosts anyways but once youve done it once it will be super fast. Ive gof my freenas server this way, nextcloud, and a few other servers. It is handy because its all going through the cert you created in letsencrypt, so freenas doesnt need a cert neither does nextcloud its all going through the main server cert which is very nice.

Sorry guys that I insist with this subject but IMO, the problem is not solved, at least from my point of view.
I said “at least my point of view” because also @syntaxerrormmm:

and @schweidj:

have suggested /requested to be used the Virtual Host Module implemented in NethServer.

The solutions presented here, in this topic, and here:
Nextcloud in new virtualhost - #2 by enzoturri
are functionally, very simple, but does not use at all the NethServer Virtual Host Module. The solutions use symlink.
Rhetorical question: why was this module (NS Virtual Host) created?

I need to use the NS VH Module because I want to set a dedicated server to host multiple websites: Nextcloud for my company, my company website based on Wordpress, other customers websites.
I need to use the NS VH Module because I want to set a dedicated server to host multiple websites: Nextcloud for my company, my company website based on Wordpress, other customers websites. There are some advantages using this module: easy to setup (the directories, the configuration file, server alias, FTP access, are automatically created), can be monitored by Web Statistics (the AWStats module by @stephdl ), are all in the same place/location (/var/lib/nethserver/vhost/****).

If the NS VH Module were to be used, it would mean that the entire content of the Nextcloud folder should be inside the VH folder created through GUI (Management → Virtual hosts), in this location: /var/lib/nethserver/vhost/nextcloud.

If we use the NS Nextcloud module (which should be the optimal solution), will be installed in this location: /usr/share/nextcloud.

So, some questions from me:

  • is there a functional procedure to move “nextcloud” from default installation path to “vhost” path and, of course, Nextcloud to be functional after that?
  • can be modified the installation process of the module so the default installation path to be chosen by the user?
  • can be modified the installation process of the module so the default installation path to be inside the real virtualhost (/var/lib/nethserver/vhost/nextcloud)?
  • common question for all three from above: will the module automatically updated?

Thank you all in advance for the patience to read this and for your future answers!


1 Like


Actually, besides NextCloud you can easily use the NS Virtual Host to host any virtual hosts (Apache, not KVM or Containers). I do run several WordPress in NethServer that way.
However: LetsEncrypt wil also NOT work out of the box for this kind of setup.

However,the NextCloud is installed from modules and should be consistant during updates. This is a different kind of “beast”. WordPress don’t actually need the AD or LDAP for users. NextCloud surely does! Even if no one can log in, a word press site is still considered functional if it just shows the content. NextCloud will not show any content except the login page if there’s no authenticated user.

If you MUST have your nextcloud available behind a URL like this:

which seems to me to be your goal, then install 2 or more NextClouds at the appropriate locations.

AFAIK: The Integrated NextCloud in NethServer doesn’t support multiple domains, the user nor admin can’t change the e-mail addresses… The E-Mail of the User in NextCloud/NethServer is always the server’s domain name.

What would work well:

Provide your NextCloud Services under

and the web-pages under

That would be really easy and quick to set up - AND no headaches during updates!!!

My 2 cents.

1 Like

Thank you @Andy_Wismer for your quickly and detailed answer!

Actually, I want to provide Nextcloud services only for my company (suggested site: cloud.mycompany.tld), using NS Nextcloud module. It works like that with @giacomo solution. So, I don’t need Nextcloud as multisite/multiple domains.

For sites based WP is another discussion, but here:

HowTo install Wordpress on NethServer

Of course, my Q&A will be based on NS Virtual hosts.:grin:


I install WP the old school way:

Create the vHost folder (Or server-root, whatever needed)

wget the right version / language needed
create the DB and users with:

mysqladmin create wpdewebsitename
mysql --user=root mysql
GRANT ALL ON wpdewebsitename.* TO wpdewebsitenameuser@localhost IDENTIFIED BY ‘secret-password’;
flush privileges;

unpack wp and set the right permissions: done!

One advantage of WordPress is it doesn’t need to be fully integrated in NethServer, I can quickly move it anywhere else simply by dumping the DB and Zipping the WP-folder.

NethServer is great for hosting like you plan to…
But you’re safe to move WP offsite if needed or requested - without disrupting your NethServer.
yum doesn’t really “need” to know about an installed WP-package. That only creates unnecessary dependencies…

BTW: I am a big believer in standardized naming conventions and principles, one of them being “speaking names”. Since 25 years, all Windows boxes i touched, you will find the CD/DVD drive on J:. Printers always use the IP 31 at the end (at least the primary, main printer). WordPress naming for DB includes two etters for WP, two letters for language (I do have several multilanguage sites, Switzerland may be small, but we use 4 languages officially!) and the Domain represented. The user involved is the same, but adding user at the end, see example above.
If I see “wpdewebsitenameuser” this in any script or log file, I know exactly it’s the database user we’re talking about, and not the database, domain or the web-folder.

I do have a lot of these naming conventions documented in PDF for at least 20 years now, if anyone’s interested…



I know.
I faced with NS WP issues when I wanted to move it in VH.
In that topic, there is a solution given by @mrmarkuz , but for me didn’t work. :sweat:
I will try again, with a little help from him, I hope! :pray:
So, till now, I have installed WP in the same “old school” as you. :grinning:


1 Like

The aim of the module is hosting your own applications like @Andy_Wismer pointed out.

Not yet, but I can implement the procedure documented in this post inside nethserver-nextcloud package.

No, this is only a matter of configuration. Since nextcloud is installed using a RPM, it doesn’t need to be installed inside the vhost dir.

Every applications which is installed by hand inside the virtual host directory, should be updated manually (or using the tools provided by the web application itself).

On the other side, the nethserver-nextcloud package can receive automatic updates.

1 Like

I’m very sorry I cannot follow through the discussion in a timely manner; tomorrow I will dedicate my spare time to provide answers and tests.

I do very much like the vhost approach; please be aware that probably some other settings may be implemented to improve/simplify user experience (e.g. removing ‘index.php’ from the URL, etc.). I’ve seen some tries, I will reproduce them tomorrow and provide feedback.

Hi, this setup is working with theNethServer release 7.5.1804 ? i get the error below when i visit my nextcloud through i try to delete 10base file and retype signal-event nethserver-nextcloud-update and i’m able to reach my nc but with wrong cert
This version of Nextcloud requires at least PHP 7.0
You are currently running 5.6.25. Please update your PHP version.

It’s no longer needed to delete any template file. You can follow the instruction in the manual instead:

Custom Virtual Host
To customize the Nextcloud web url:

config setprop nextcloud VirtualHost
config setprop nextcloud TrustedDomains
signal-event nethserver-nextcloud-update

If you use let’s encrypt remember to add the domain name to the proper list.


Hello to all,

Long time system user, first time poster.

I downloaded NethServer just because of that passage in the manual…
Unfortunately, it does not work. Made a clean install.

  1. yum update all
  2. Enabled AD
  3. Installed NextCloud
  4. Created virtual host
  5. Run Lets encrypt
    5 Run the:config setprop nextcloud VirtualHost config setprop nextcloud TrustedDomains signal-event nethserver-nextcloud-update

I am running the latest with all updates:
System version NethServer release 7.6.1810 (final)
Kernel release 3.10.0-957.12.1.el7.x86_64

The resulting virtual host serves the default nethserver html on the https, but no nextcloud. Not even the alias /nextcloud works anymore…

Thanks for the great work and effort put into this.

Kind regards,

You shouldn’t have done this, assuming that virtual host is Delete that virtual host, and I’d expect you should be fine.

I removed the subdomain
Now on that subdomain i receive:

Service Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
[07/May/2019:13:51:59 +0200] “GET / HTTP/1.1” 503 299
[07/May/2019:13:57:11 +0200] “GET /nextcloud HTTP/1.1” 503

I even reinstalled nextcloud…

Plus the certificate for subdomain isn’t configured. It uses the generated by the server.

  1. cat /etc/httpd/conf.d/zz_nextcloud.conf
  2. Config
    # config show nextcloud