YaSt HTTP server - Multiple VirtualHost

Hello,

New to openSUSE, I’m exploring and trying to readapt me from Debian and FreeBSD.
I’m trying to configure 2 different hosts for a test : “host1.lan” and “host2.lan”.
I do it from terminal, no problem. But I don’t succeed with YaSt HTTP Server, and I don’t know why.
Maybe someone can explain me what I’m doing wrong ?

openSUSE (Server) is installed on a VM in VirtualBox, bridged interface. It’s Leap 15.3
I want to access the websites from my computer host, by adding 2 lines to /etc/hosts (I’m also on openSUSE but with KDE for Desktop)
(echo “IP-SRV-SUSE host1.lan” >> /etc/hosts
echo “IP-SRV-SUSE host2.lan” >> /etc/hosts)

I) from terminal : it works.
Here are the settings for host1.lan



su -

zypper in -y apache2 && systemctl enable apache2

mkdir -p /srv/www/host1.lan
echo “welcome to host1.lan” > /srv/www/host1.lan/index.html

cd /etc/apache2/vhosts.d/
cp vhost.template host1.lan.conf

vi host1.lan.conf

<VirtualHost *:80>
ServerName host1.lan
DocumentRoot /srv/www/host1.lan
ErrorLog /var/log/apache2/host1.lan-error_log
CustomLog /var/log/apache2/host1.lan-access_log combined
<Directory “/srv/www/host1.lan”>
Require all granted

ESC :wq

systemctl restart apache2

systemctl start firewalld
firewall-cmd --add-port=80/tcp
firewall-cmd --runtime-to-permanent




Now, host2.lan (same method)



mkdir -p /srv/www/host2.lan
echo “welcome to host2.lan” > /srv/www/host2.lan/index.html

cd /etc/apache2/vhosts.d/
cp vhost.template host2.lan.conf

vi host2.lan.conf

<VirtualHost *:80>
ServerName host2.lan
DocumentRoot /srv/www/host2.lan
ErrorLog /var/log/apache2/host2.lan-error_log
CustomLog /var/log/apache2/host2.lan-access_log combined
<Directory “/srv/www/host2.lan”>
Require all granted

ESC :wq

systemctl restart apache2





I have the 2 websites working from the browser of my host.. (http://host1.lan and http://host2.lan).






II) Now, the problem : YaSt HTTP Server.
For this example, I will add another vhost (host3.lan).



mkdir -p /srv/www/host3.lan
echo “welcome to host3.lan” > /srv/www/host3.lan/index.html
zypper in -y yast2-http-server
yast



# Network Services -&gt; HTTP Server
It detects my manual configurations for host1.lan and host2.lan,, tells me that my settings could be dropped, I go on.


First, I "Open Port in Firewall" (80). Then Next.
Secondly, the Main Host, I change nothing. All By default.
I see host1 and host2 in the Hosts tab, I explore and notice the settings.. in order to know how to do it for host3.lan


So, I add host3.lan
here is the configuration for host3.lan


Server Identification
Server Name :
host3.lan
Server Contents Root :
/srv/www/host3.lan
Administrator E-Mail
[EMAIL="webmaster@nothing.com"]webmaster@nothing.com[/EMAIL]


Server Resolution
VirtualHost (x) Determine Request Server by HTTP Headers
*:80 ( ) Determine Request Server by Server IP Address


Directory Index
/srv/www/host3.lan


I Finish with YaSt, come back to my computer add the host3.lan to my /etc/hosts and when I try to access from my browser (http://host3.lan)
tadam... I access to... host1.lan index.html !
host2.lan also become host1.lan.
And when I try to access to host2.lan, I access host1 index also ! And I checked everything, index.html are all specific to the vhosts. path are all ok to... what's wrong ?!


Maybe I don't understand how to create several virtualhosts with YaSt HTTP Server...
I know how to do mannually, but not with YaSt...


Anyone can explain me ? Or send me to a howto with yast http server configuration with several vhosts ?

If you look at generated configuration, YaST creates VitrualHost directives with “" without explicit port number and template has ":80” with explicit port number. My best guess is that more specific directive wins.

If you create all of them using YaST, it works correctly.

Interesting. Thank You, I’ll check that :slight_smile: