VirtualHosts issue, multiple sites

So i have read all the documentation, and I have an issue. I know debian very well, and just moved from a debian system. Virtualhosts do not give me an option to map sites to their respective locations (/var/www/sitename.com/public_html, /var/www/site2name.com/public_html). I can set up hosts for my sites, ftp in the the default mapped location, upload a php info file and when I load up the sites on the net they both go to the nethserver default site page, saying upload to /var/www/html. I cannot do this because I have multiple sites, that need to be set up with ssl. I currently have removed the virtual hosts, manually added site1, site2.com.conf files in httpd, which apparently work to an extent as I go to said sites ssl works and forced HTTPS works but It does not map to my files even though in site.com.conf I have directory set to /var/www/site.com/public_html. I would do it manually but the conf files needed are regenerated every load so how am I supposed to add more than one site? Thanks!

Virtual hosts module have been created to do exactly what you’re looking for.

The module is almost a simple web interface to Apache virtual host config files.
Of course, you need to access every site with its own host name.

I used virtual hosts, but for some reason I cant get rid of the nethserver landing page. I have a php test script in both my domains, which works, but if I try to go to a subdomain, sub.mydomain.com, I get a nethserver default page. I set up a subdomain through virtual hosts and that seems to work but any other subdomain I do not have set up doesnt time out, it goes to a landing page. any way to disable it? Also I have cloud.mydomain.com and i want to point it to an ip on my network. I edited dns, set up a host and a alias but it will not forward…what am i doing wrong? Thanks! You guys are amazing.

Just drop an index.html inside /var/www/html.

You need a proxy pass for this, if you need to redirect a whole domain, you need to do it by hand.
Take a look at this: https://httpd.apache.org/docs/2.4/vhosts/examples.html#proxy

Awesome! I usually do all this by hand through terminal I just wanted to make sure I wasn’t overlooking anything after reading the documentation. Thanks! You’re the best. Moved from Zentyal and not regretting it. Support has been phenomenal. Plus Ive used Debian for years, time for a switch.

Thanks man, we really appreciate your compliments! Bear in mind that community belongs to all of us
Would you like to help us to take over the Debian world? :grinning:

So I have made a reverse proxy to my internal ip, currently its cloud.mysite.com to a nextcloud instance on freenas on another server. http works flawlessly as expected but when I force ssl through mod_ssl and mod_rewrite

RewriteEngine on
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301]

When I do this it automatically goes to the nethserver test page. When I remove ssl it works fine. I have a cert for my domain, and it works for mysite.com, but cloud.mysite.com fails. It redirects to /var/www/html, instead of respecting the virtualhost conf I have set up in SitesAvailable/SitesEnabled.

Edit: Oops I am an idiot, didn’t set separate vhosts for :80 and :443 I feel super stupid. Thanks for all your help!

1 Like