Re: [users@httpd] How can I configure “apache2” correctly using multiple sites through VirtualHost?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



20 Apr 2021, at 06:25, Marcel Roșca <roscamarcel88@xxxxxxxxx> wrote:
> I configured two sites using the "VirtualHost" method in apache2, but if there is an error in the first configuration file when I call my site, it enters the second site. my configuration files are:

This is very confusing. Using white space to set off the two files and you comments would be helpful. Bonus points for a clear indents and structure.

> 1: audio-castle.live:
> <VirtualHost *:80>
>   Protocols h2
>   Redirect / https://audio-castle.live
> </VirtualHost>

> <IfModule mod_ssl.c>
> <VirtualHost *:443>

For what it's worth, my configurations all list the web server IP in the 443 VirtualHost. I seem to recall having issues if I used *. YMMV.

>   Protocols h2
>   ServerName audio-castle.live
>   ServerAlias www.audio-castle.live
>   ServerAdmin
>   DocumentRoot /var/www/audiocastle/web

Document root requires a final / (I think this was a bad decision in the parsing of the config file and causes far more trouble than allowing document roors without a final / could ever solve, but I did not get a vote).

>   ErrorLog ${APACHE_LOG_DIR}/error.log

Where is APACHE_LOG_DIR defined? If it's defined outside this file, pretty sure that doesn't work.

>   CustomLog ${APACHE_LOG_DIR}/access.log combined
>   SSLEngine on
>   Include /etc/letsencrypt/options-ssl-apache.conf
>   SSLCertificateFile /etc/letsencrypt/live/audio-castle.live/fullchain.pem
>   SSLCertificateKeyFile /etc/letsencrypt/live/audio-castle.live/privkey.pem
>   <Directory /var/www/audiocastle/web>
>     AllowOverride All
>   </Directory>
> </VirtualHost>
> </IfModule>

This virtualhost only exists inside your ifmodule, so if it is not loading the virtaulost, it is probably because of this. I have no idea why you have an if module at all, since your virtual host is defined as listening to port 443. What are you expecting that if module to do? If it is loading, I would expect alt you would get a 404 error on "https://audio-castle.liveindex.html";.

> the second file is: gtdvm.com:

And when you say it is the second file, are you sure that it is SECOND as far as apache is concerned? `apachectl -S` will list your virtual configurations in the order apache loads them.

> the problem is when an error occurs in one of these two files, when I access for example audio-castle.live, I reach the site gtdvm.com, if the error is in the audio-castle.live file. my question is: how to avoid this redirect from one site to another when one of them encounters errors? . I use Ubuntu 20.04, apache2.4.46.

The way to avoid errors is to check your configuration for errors with `apachectl -t`, `apachectl -S`  and maybe `apachectl -X` if you are still having troubles.

I suspect that what you think is your "second file" is the only one being loaded.


-- 
"We take off our Republican hats and put on our American hats" --
	Many Republicans in Sep 2008


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx





[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux