logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in  RSS Apache Lounge  


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.



Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: ServerAlias not working on vhost
Author
lpark



Joined: 06 Nov 2020
Posts: 9
Location: Germany

PostPosted: Fri 06 Nov '20 12:57    Post subject: ServerAlias not working on vhost Reply with quote

Hello,
I'm deploying my vueJs app with a vhost. Everything works fine when calling the page by the IP address. But when trying to visit the page by the ServerAlias it's not working. Using ubuntu 16.04.7 LTS.

Here's my testServer.conf (vhost configuration)


Code:
<VirtualHost *:80>
    ServerName testConnection.test
    ServerAlias www.testConnection.test
    ServerAdmin webmaster@test.de
    DocumentRoot /var/www/client/pvapp-client/dist

    <Directory /var/www/client/pvapp-client/dist>
        Options -Indexes +FollowSymLinks
        Allow from all
        AllowOverride All

        RewriteEngine on

        RewriteCond %{REQUEST_FILENAME} -s [OR]
        RewriteCond %{REQUEST_FILENAME} -l [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^.*$ - [NC,L]
        RewriteRule ^(.*) /index.html [NC,L]
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/test.com-error.log
    CustomLog ${APACHE_LOG_DIR}/test.com-access.log combined
</VirtualHost>


I also edited the hosts file like:
Code:
127.0.0.1       localhost
192.168.51.68   www.testConnection.test
192.168.51.47   www.testConnection.test


Also enabled the conf file with
Code:
sudo a2ensite testServer.conf


Thanks for all help.
Back to top
tangent



Joined: 16 Aug 2020
Posts: 19
Location: UK

PostPosted: Fri 06 Nov '20 22:03    Post subject: Reply with quote

Does your site respond as expected to both IP addresses, namely 192.168.51.47 and 192.168.51.68?

If so, you have two IP's allocated to www.testConnection.test, so which would you choose if you were trying to resolve ServerAlias? Locally, I'd say the first host entry would be chosen by Ubuntu.

Also. presume there's a host entry for testConnection.test too?
Back to top
lpark



Joined: 06 Nov 2020
Posts: 9
Location: Germany

PostPosted: Mon 09 Nov '20 11:20    Post subject: Reply with quote

The first IP works, the second doesn't. So I guess I'd just remove it then.

What do you mean by host entry?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 6859
Location: Germany, Next to Hamburg

PostPosted: Mon 09 Nov '20 16:08    Post subject: Reply with quote

lpark wrote:

What do you mean by host entry?


one host entry is

Code:

127.0.0.1       localhost


Why do is testConnection.test and testConnection.test not in hosts file?
Also you can have / should have only one try per host name.
Back to top
lpark



Joined: 06 Nov 2020
Posts: 9
Location: Germany

PostPosted: Mon 09 Nov '20 16:53    Post subject: Reply with quote

Okay, but I wrote testConnection.test in this file with the IP 192.168.51.47?
And 127.0.0.1 should be localhost, or not?

I removed the other.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 6859
Location: Germany, Next to Hamburg

PostPosted: Wed 11 Nov '20 12:37    Post subject: Reply with quote

on the server you only need 127.0.0.1 localhost in /etc/hosts

on the requesting client you need

Code:

127.0.0.1       localhost
192.168.51.47   testConnection.test
192.168.51.47   www.testConnection.test
Back to top
lpark



Joined: 06 Nov 2020
Posts: 9
Location: Germany

PostPosted: Thu 12 Nov '20 11:11    Post subject: Reply with quote

Okay, thank you. Smile
Back to top


Reply to topic   Topic: ServerAlias not working on vhost View previous topic :: View next topic
Post new topic   Forum Index -> Apache