Results 1 to 2 of 2

Thread: apache vhosts namebasd boken?

  1. #1

    Default apache vhosts namebasd boken?

    Hi all

    Need to setup a few webbased services for our intranet. Some o them are currently running on a server which is still on 13.1. The new server is a server upgraded from 13.1 to 13.2. It works flawlessly apart from apache, that is to say, as soon as I try to get some vhosts up, things start to be screwy.

    Initially apache was installed still under 13.1 but never used and finally upgraded when moving to 13.2 by the "zypper dup" method well discribed here . There were no errors, so I thought it would all be fine. As the troubles started, I decided to uninstall all apache packes lists in "yast sw_single" and removed them, removed /etc/apache completely, rebooted and reinstalled them the same Yast way.

    That's installed for now
    Code:
    rpm -qa | grep apache
    apache2-2.4.10-1.1.x86_64
    apache2-prefork-2.4.10-1.1.x86_64
    apache2-example-pages-2.4.10-1.1.x86_64
    apache2-utils-2.4.10-1.1.x86_64
    apache2-mod_php5-5.6.1-4.1.x86_64
    apache2-doc-2.4.10-1.1.noarch
    Then I used Yast again to set the basics, a popup appears saying
    Code:
    Files /etc/sysconfig/apache2, /etc/apache2/default-server.conf have been changed manually.
     YaST might lose some of the changes                                                       │ 
     [ ] Do not show this message anymore
    I click in coninue, not to forget to mention, that this is a bit puzzling since at least "/etc/apache2/default-server.conf" was deleted and also I need to "rm /etc/sysconfig/apache2" if I need to reinstall apach again. One more remark here, /etc/sysconfig/apache2 is dated Nov. 19 2014 and definetely not touched by myself, so it should virgin. I click on continue and satisfy myself that there is no alien setting. I close the dialogue and get another poup saying:

    Code:
    Warning
      When no Server name is defined, hostname will be used instead.
    Clicking on "OK" and over to see, if apache actually runs:

    Code:
    httpd2 -S
    VirtualHost configuration:
    ServerRoot: "/srv/www"
    Main DocumentRoot: "/srv/www/htdocs"
    Main ErrorLog: "/var/log/apache2/error_log"
    Mutex ssl-stapling: using_defaults
    Mutex ssl-cache: using_defaults
    Mutex default: dir="/run/" mechanism=default 
    Mutex mpm-accept: using_defaults
    PidFile: "/run/httpd.pid"
    Define: DUMP_VHOSTS
    Define: DUMP_RUN_CFG
    User: name="wwwrun" id=30
    Group: name="www" id=8
    
    systemctl start apache2
    
    systemctl status apache2 -l
    apache2.service - The Apache Webserver
       Loaded: loaded (/usr/lib/systemd/system/apache2.service; disabled)
       Active: active (running) since Mon 2014-12-29 13:46:02 CET; 2s ago
     Main PID: 4043 (httpd2-prefork)
       Status: "Processing requests..."
       CGroup: /system.slice/apache2.service
               ├─4043 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf -DSSL -D SYSTEMD -DFOREGROUND -k start
               ├─4060 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf -DSSL -D SYSTEMD -DFOREGROUND -k start
               ├─4061 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf -DSSL -D SYSTEMD -DFOREGROUND -k start
               ├─4062 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf -DSSL -D SYSTEMD -DFOREGROUND -k start
               ├─4063 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf -DSSL -D SYSTEMD -DFOREGROUND -k start
               └─4064 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf -DSSL -D SYSTEMD -DFOREGROUND -k start
    Server brutus is up and name resolution is working:
    Code:
    ping -c1 brutus
    PING brutus.k23.lan (192.168.23.4) 56(84) bytes of data.
    64 bytes from brutus.k23.lan (192.168.23.4): icmp_seq=1 ttl=64 time=0.040 ms
    
    --- brutus.k23.lan ping statistics ---
    1 packets transmitted, 1 received, 0% packet loss, time 0ms
    rtt min/avg/max/mdev = 0.040/0.040/0.040/0.000 ms
    on a client I surf to "brutus.k23.lan" and I get the reply "It works" as defined :
    Code:
    /srv/www/htdocs # cat index.html 
    <html><body><h1>It works!</h1></body></html>
    So far so well. Proof, apache works and is running, if st up as a single server. Now up and away to vhost setup:

    I use Yast again and define the folloing two vhosts for now. I want to set them up namebased, so I need to setup name resolution, testing it for vhost "k23" and vhost "wiki":
    Code:
    ping -c1 k23
    PING k23.k23.lan (192.168.23.4) 56(84) bytes of data.
    64 bytes from brutus.k23.lan (192.168.23.4): icmp_seq=1 ttl=64 time=0.031 ms
    
    --- k23.k23.lan ping statistics ---
    1 packets transmitted, 1 received, 0% packet loss, time 0ms
    rtt min/avg/max/mdev = 0.031/0.031/0.031/0.000 ms
    works, so off to "yast HTTP Server" and get the config files for those two vhosts done:
    Code:
      New Host Information
       ┌Server Identification───────────────────────────────────────────────────────────────────┐ 
       │Server Name:                                                                                                                                                         │ 
      │k23▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│ 
       │Server Contents Root:                                                        [Browse...]                                                                 │ 
       │/srv/www/intranet/k23.k23.lan▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒                       │ 
       │Administrator E-Mail:                                                                                                                                            │
       │sc@k23.lan▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│ 
       └─────────────────────────────────────────────────────────────────────────────────┘ 
     
       ┌Server Resolution────────────────────────────────────────────────────────────────────┐ 
       │VirtualHost                    (x) Determine Request Server by HTTP Headers                                                               │ 
       │▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒( ) Determine Request Server by Server IP Address                            │ 
       │[Change VirtualHost ID]                                                                                                                                      │ 
      └────────────────────────────────────────────────────────────────────────────────┘
    I cannot leave the dialogue, if I do not click on "Change VirtualHost ID". The pop up upening thereafter leaves no choice really, which puzzles me a bit:
    Code:
      ┌─────────────────────┐
    │(x) All addresses (*)              │
    │┌IP Addresses───────┐      │
    ││[ ] 127.0.0.1                │     │
    ││[ ] 192.168.1.44          │     │
    ││[ ] 192.168.23.4          │      │
    └───────────────────┘ │
     │ServerName                         │ 
    │▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
    │                                            │ 
    │                                            │ 
    │    [OK] [Cancel]                    │
    └─────────────────────┘
    There is nothing that could be changed, only options are "OK" and "Cancel", to continue I click on "OK". And repeat the procedure for second vhost named wiki.k23.lan. What if I do not want the pages to be served on one of the listed addresses? I dunno, but I guess that the checkboxes really should be selectable, right?

    Anyway, the files are like this:

    Code:
    cat k23*.conf
    <VirtualHost *>
     DocumentRoot /srv/www/intranet/k23.k23.lan
     ServerName k23
     ServerAdmin ck@k23.lan
     <Directory /srv/www/intranet/k23.k23.lan>
      AllowOverride None
      Require all granted
     </Directory>
    </VirtualHost>
    
    cat wiki*.conf
    <VirtualHost *>
     DocumentRoot /srv/www/intranet/wiki.k23.lan
     ServerName wiki.k23.lan
     ServerAdmin ck@k23.lan
     <Directory /srv/www/intranet/wiki.k23.lan>
      AllowOverride None
      Require all granted
     </Directory>
    </VirtualHost>
    See if it runs:

    Code:
    systemctl status apache2 -l
    apache2.service - The Apache Webserver
       Loaded: loaded (/usr/lib/systemd/system/apache2.service; disabled)
       Active: inactive (dead)
    
    Dez 29 14:10:30 brutus start_apache2[5253]: AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/apache2/default-server.conf:100
    
    httpd2 -S
    AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/apache2/default-server.conf:100
    VirtualHost configuration:
    *:*                    is a NameVirtualHost
             default server k23 (/etc/apache2/vhosts.d/k23.conf:1)
             port * namevhost k23 (/etc/apache2/vhosts.d/k23.conf:1)
             port * namevhost wiki.k23.lan (/etc/apache2/vhosts.d/wiki.k23.lan.conf:1)
    ServerRoot: "/srv/www"
    Main DocumentRoot: "/srv/www/htdocs"
    Main ErrorLog: "/var/log/apache2/error_log"
    Mutex ssl-stapling: using_defaults
    Mutex ssl-cache: using_defaults
    Mutex default: dir="/run/" mechanism=default 
    Mutex mpm-accept: using_defaults
    PidFile: "/run/httpd.pid"
    Define: DUMP_VHOSTS
    Define: DUMP_RUN_CFG
    User: name="wwwrun" id=30
    Group: name="www" id=8
    Googling for "AH00548: NameVirtualHost" gives a lot of results, many of them referring to apache 2.2, but I am running apache 2.4 (see rpm query above: apache2-2.4.10-1.1.x86_64). Errormessage lets me think, that might be a leftover from upgrading from 13.1 to 13.2. But then how come? I removed all apache files? Puzzling level several degrees up ?!?. Ok, lets outcomment those "NameVirtualHost lines then:

    Code:
    tail -n 5 default-server.conf 
    IncludeOptional /etc/apache2/conf.d/*.conf
    
    # The manual... if it is installed ('?' means it won't complain)
    IncludeOptional /etc/apache2/conf.d/apache2-manual?conf
    NameVirtualHost *
    
    brutus:/etc/apache2 # tail -n 5 default-server.conf 
    IncludeOptional /etc/apache2/conf.d/*.conf
    
    # The manual... if it is installed ('?' means it won't complain)
    IncludeOptional /etc/apache2/conf.d/apache2-manual?conf
    # NameVirtualHost *
    
    systemctl restart apache2
    systemctl status apache2 -l
    apache2.service - The Apache Webserver
       Loaded: loaded (/usr/lib/systemd/system/apache2.service; disabled)
       Active: active (running) since Mon 2014-12-29 14:27:03 CET; 2s ago
     Main PID: 5421 (httpd2-prefork)
       Status: "Processing requests..."
       CGroup: /system.slice/apache2.service
               ├─5421 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf -DSSL -D SYSTEMD -DFOREGROUND -k start
               ├─5438 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf -DSSL -D SYSTEMD -DFOREGROUND -k start
               ├─5439 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf -DSSL -D SYSTEMD -DFOREGROUND -k start
               ├─5440 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf -DSSL -D SYSTEMD -DFOREGROUND -k start
               ├─5441 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf -DSSL -D SYSTEMD -DFOREGROUND -k start
               └─5442 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf -DSSL -D SYSTEMD -DFOREGROUND -k start
    surfing to k23.k23.lan and wiki.k23.lan now says "k23: it works" and "wiki: it works". To sum it up for now:

    • the yast HTTTP Server module seems to be probably buggy in 13.2. Namely
      • on a fresh install, it should realise that the apache related config files are untouched
      • when setting up a vhost, it should be possible to select the IP that the vhost is beeing served

    • in "default-server.conf" # NameVirtualHost * needs to be removed. Why is that not done in a fresh install of apache?


    I posted all this, as a refernce for others that may experince similar whoes with apache and hope it is of any use. Maybe ther is a bug in the yast HTTP server module. If other do get similar problems, kindly reply here. If so, I might file a bug later.

    greez

    chris

  2. #2

    Default Re: apache vhosts namebasd boken?

    Hi all

    I thought maybe troubles are over. I was wrong. In "default-server.conf" I commented out # NameVirtualHost * and it ran. However, after a few restarts, I started to see vhosts disapear. Wondering how come, I checked

    Code:
    # ls /etc/apache/2vhosts.d
    ip-based_vhosts.conf  vhost-ssl.template  vhost.template
    What's that : "ip-based_vhosts.conf "? I am absolutely sure, I did *not* make such a file! And besides, where are my *.k23.lan.conf files for my - thought so - namebased vhosts? There is none, so
    Code:
    #cat /etc/apache2/vhosts.d/ip-based_vhosts.conf
    <VirtualHost *>
     DocumentRoot /srv/www/intranet/wiki.k23.lan
     ServerName wiki.k23.lan
     ServerAdmin ck@k23.lan
     <Directory /srv/www/intranet/wiki.k23.lan>
      AllowOverride None
      Require all granted
     </Directory>
    </VirtualHost>
    <VirtualHost *>
     DocumentRoot /srv/www/intranet/k23.k23.lan
     ServerName k23
     ServerAdmin ck@k23.lan
     <Directory /srv/www/intranet/k23.k23.lan>
      AllowOverride None
      Require all granted
     </Directory>
    </VirtualHost>
    Sure enough, something has mangled my properly defined namebased vhosts into IP based vhosts. Going to Yast HTTP Server module, Hosts Tab, I am able to call all the vhosts and yess, the vhosts are now *all* IP-based. How come? OK, We had a party, but I was not touching the system until this morning, requiring a few restarts of apache. Did not go into Yast HTTP Server module until now.

    How can I teach Yast / apache to just use vhosts namebased?

    Any help greatly appreciated.

    greez

    chris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •