Menu

#5508 Incorrect document section when creating vhosts.

1.981
open
nobody
None
3
2022-03-19
2021-09-30
No

Webmin creates incorrect vhost directives on openSUSE when used with Apache 2.4.43. the

The document decleration is incorrect, on appache 2.4 the allow from all is not valid and therefore causes the Apache2 deamon to fail when restarting.

This is what Webmin is creating:

<virtualhost *="">
DocumentRoot "/srv/www/example.com"
ServerName example.com
<directory "="" srv="" www="" example.com"="">
allow from all
Options None
Require all granted
</directory>
</virtualhost>

This is how it should look on Apache 2.4:

<virtualhost *="">
DocumentRoot "/srv/www/example.com"
ServerName example.com
<directory "="" srv="" www="" example.com"="">
Options None
Require all granted
</directory>
</virtualhost>

This can be fixed by tweaking the CGI script slightly as follows:

if ($in{'adddir'} && $in{'root'}) {
# Add a <directory> section for the root
$dirsect = { 'name' => 'Directory',
'value' => "\"$in{'root'}\"",
'type' => 1,
'members' => [
{ 'name' => 'Options',
'value' => 'None' },
],
};
if ($httpd_modules{'core'} <= 2.4) {
# Apache 2.2 and below needs a "allow from all" line
push(@{$dirsect->{'members'}},
{ 'name' => 'allow',
'value' => 'from all' });
}
if ($httpd_modules{'core'} >= 2.4) {
# Apache 2.4+ needs a 'Require all granted' line
push(@{$dirsect->{'members'}},
{ 'name' => 'Require',
'value' => 'all granted' });
}
push(@mems, $dirsect);
}</directory>

I appologise if I cause any offence by proposing the solution a solution in the bug report, I just thought it may help.

Thanks
Chris
CoE Engineer - End User Compute

Related

Bugs: #5508

Discussion

  • Christopher Wager

    Hi Jamie,

    It included both the "allow from all" and "require all granted" in the .vhost which would cause apache to fail to start on a syntax error.

    Apologies for not explaining.

    Thanks
    Chris
    Get Outlook for Androidhttps://aka.ms/AAb9ysg


    From: Christopher Wager stargazer2021@users.sourceforge.net
    Sent: Thursday, 30 September 2021, 07:31
    To: Ticket #5508: Incorrect document section when creating vhosts.
    Subject: [webadmin:bugs] #5508 Incorrect document section when creating vhosts.


    [bugs:#5508]https://sourceforge.net/p/webadmin/bugs/5508/ Incorrect document section when creating vhosts.

    Status: open
    Group: 1.981
    Created: Thu Sep 30, 2021 06:31 AM UTC by Christopher Wager
    Last Updated: Thu Sep 30, 2021 06:31 AM UTC
    Owner: nobody

    Webmin creates incorrect vhost directives on openSUSE when used with Apache 2.4.43. the

    The document decleration is incorrect, on appache 2.4 the allow from all is not valid and therefore causes the Apache2 deamon to fail when restarting.

    This is what Webmin is creating:

    <virtualhost *="">
    DocumentRoot "/srv/www/example.com"
    ServerName example.com
    <directory "="" srv="" www="" example.com"="">
    allow from all
    Options None
    Require all granted
    </directory>
    </virtualhost>

    This is how it should look on Apache 2.4:

    <virtualhost *="">
    DocumentRoot "/srv/www/example.com"
    ServerName example.com
    <directory "="" srv="" www="" example.com"="">
    Options None
    Require all granted
    </directory>
    </virtualhost>

    This can be fixed by tweaking the CGI script slightly as follows:

    if ($in{'adddir'} && $in{'root'}) {

    Add a <directory> section for the root</directory>

    $dirsect = { 'name' => 'Directory',
    'value' => "\"$in{'root'}\"",
    'type' => 1,
    'members' =>
    { 'name' => 'Options',
    'value' => 'None' },
    https://sourceforge.net/{%20'name'%20=%20'Options',
    %20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20'value'%20=>%20'None'%20},>,
    };
    if ($httpd_modules{'core'} <= 2.4) {

    Apache 2.2 and below needs a "allow from all" line

    push(@{$dirsect->{'members'}},
    { 'name' => 'allow',
    'value' => 'from all' });
    }
    if ($httpd_modules{'core'} >= 2.4) {

    Apache 2.4+ needs a 'Require all granted' line

    push(@{$dirsect->{'members'}},
    { 'name' => 'Require',
    'value' => 'all granted' });
    }
    push(@memshttps://sourceforge.net/u/mems/, $dirsect);
    }

    I appologise if I cause any offence by proposing the solution a solution in the bug report, I just thought it may help.

    Thanks
    Chris
    CoE Engineer - End User Compute


    Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/webadmin/bugs/5508/

    To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

     

    Related

    Bugs: #5508

  • Jamie Cameron

    Jamie Cameron - 2022-02-06

    Thanks for the info!

    Can you post the exact Apache error message? I'm surprising that the "Allow" directive isn't allowed, as it's still listed in the docs : https://httpd.apache.org/docs/2.4/mod/mod_access_compat.html#allow

     
  • Ilia

    Ilia - 2022-03-19

    Christopher, any update on this?

     

Log in to post a comment.

Auth0 Logo