[lug] Apache Virtual Hosting Question

duboulder blug-mail at duboulder.com
Wed Apr 3 23:06:38 MDT 2019


I haven't used apache in quite a while, but maybe my questions will help you
figure it out.

1) Do you really mean you are trying to use //url-space/path instead of /url-space/path?
    E.g. if site1.local's root maps to /var/www/site1, then a site relative css link reference
    would be <link type="text/css" rel="stylesheet" href="/css/main.css"/> where
    /var/www/site1/css/main.css is the external stylesheet.
2) Do the apache access logs or the ua debug consoles show the css request going
    to the host-name you expect? The web-console in ff has a network tab that will show
    you what resource urls are being fetched. I expect chrome has something similar.

    wget --save-headers --header='Host: site1.local' [http://ip.add.re.ss:port/](http://ip.add.re.ss/) -O site1.html
    wget --save-headers --header='Host: site2.local' [http://ip.add.re.ss:port/](http://ip.add.re.ss/) -O site2.html
    If these files don't differ your vhost configuration isn't doing what you want.
3) An apache vhost needs more than just a name/address/port. It also needs to specify
    the root directory that maps to the url http://site1.local/. Might also need access
    control settings. Your sites can use the same address/port, just need different host
    names. The vhost functionality is probably enabled by default, but you may want check
    that. IIRC the status page (if enabled) will also show builtin modules.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Wednesday, April 3, 2019 6:19 PM, D. Stimits <stimits at comcast.net> wrote:

> I ran into a case where I wanted to test a couple of independent web "creations" on my Fedora system. So I set up virtual names, and my "/etc/hosts" has a couple of different domains. The content is in different subdirectories of "/var/www/". Within the actual html/css I'm trying to learn to a bit more modern, and so for example I've referred to some URLs via the "//use/the/requesting/protocol/instead/of/hard/coding/" syntax. Only this doesn't work for external CSS.
>
> If I don't actually code the explicit name into the URL it doesn't work. I didn't want to do mod_rewrite, but I did want to html/css to be portable without embedding a host name into it. Should I be running more than one server instance on different ports instead of working with virtual servers?
>
> I would hope that if I refer to a site as "http://custom", and "custom" is in "/etc/hosts", that any relative URLs in the html would also assume that "custom", but it doesn't seem to be the case.
>
> Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lug.boulder.co.us/pipermail/lug/attachments/20190404/3e23b015/attachment.html>


More information about the LUG mailing list