Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Confusing Apache2 alias issue, anyone?

Off-Topic discussions about science, technology, and non Debian specific topics.
Post Reply
Message
Author
c-tz
Posts: 5
Joined: 2018-02-11 20:19

Confusing Apache2 alias issue, anyone?

#1 Post by c-tz »

Hi,

I'm having issues with a very simple apache2 configuration and for the life of me can't figure out why it's not working. Maybe it's because I haven't done proper apache2 configuration in a year or so, I'm so convinced this should work. Can someone have a look with me?

Let me explain what I'm trying to do:
I have a local setup where i go to for example 192.168.1.10/a or 192.168.1.10/b. When I use http:// infront, I want it to redirect to https.
These are also reachable through DNS using a.domain.com and b.domain.com. Same redirecting http:// to https://

There are two .conf files activated, A and B. Both are enabled using a2ensite, as is 000-default.conf (not default-ssl, that's off):

a.conf

Code: Select all

NameVirtualHost *:80
<VirtualHost *:80>
        ServerName a.domain.com
        Alias /a "/var/www/a"
        DocumentRoot /var/www/a
        Redirect permanent "/" "https://a.domain.com"
        
        RewriteEngine On
        RewriteCond %{HTTPS} off
        RewriteRule ^/?(.*) https://%{HTTP_HOST}/%{REQUEST_URI} [R,L]
</VirtualHost>
<VirtualHost *:443>
        ServerName a.domain.com
        Alias /a "/var/www/a"
        DocumentRoot /var/www/a

        <Directory "/var/www/a/">
                Options -Indexes +FollowSymLinks
                AllowOverride None
                Require all granted
        </Directory>

        SSLEngine On
        SSLCertificateFile /etc/ssl/localcerts/apache.pem
        SSLCertificateKeyFile /etc/ssl/localcerts/apache.key
</VirtualHost>
b.conf

Code: Select all

NameVirtualHost *:80
<VirtualHost *:80>
        ServerName b.domain.com
        Alias /b "/var/www/b"
        DocumentRoot /var/www/b
        Redirect permanent "/" "https://b.domain.com"
        
        RewriteEngine On
        RewriteCond %{HTTPS} off
        RewriteRule ^/?(.*) https://%{HTTP_HOST}/%{REQUEST_URI} [R,L]
</VirtualHost>
<VirtualHost *:443>
        ServerName b.domain.com
        Alias /b "/var/www/b"
        DocumentRoot /var/www/b

        <Directory "/var/www/b/">
                Options -Indexes +FollowSymLinks
                AllowOverride None
                Require all granted
        </Directory>

        SSLEngine On
        SSLCertificateFile /etc/ssl/localcerts/apache.pem
        SSLCertificateKeyFile /etc/ssl/localcerts/apache.key
</VirtualHost>
It's working perfectly when I try to reach them through their external links. When I visit 192.168.1.10/a it's working too, but as soon as I try to reach 192.168.1.10/b it says "The requested URL /b was not found on this server."
The most important part is that it works when visiting the domain name, but I want to get it to work through internal IP too. After two days decided to ask for help

Can someone come up with an idea why this isn't working?
Or if you'd care to share how you would do this, please go ahead.

Using latest Debian on a fresh test server with updates. I purged apache2 + php and reinstalled them, so everything is vanilla.

Post Reply