Author |
|
lpark
Joined: 06 Nov 2020 Posts: 9 Location: Germany
|
Posted: Fri 06 Nov '20 12:57 Post subject: ServerAlias not working on vhost |
|
|
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 Moderator
Joined: 16 Aug 2020 Posts: 348 Location: UK
|
Posted: Fri 06 Nov '20 22:03 Post subject: |
|
|
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
|
Posted: Mon 09 Nov '20 11:20 Post subject: |
|
|
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: 7371 Location: Germany, Next to Hamburg
|
Posted: Mon 09 Nov '20 16:08 Post subject: |
|
|
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
|
Posted: Mon 09 Nov '20 16:53 Post subject: |
|
|
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: 7371 Location: Germany, Next to Hamburg
|
Posted: Wed 11 Nov '20 12:37 Post subject: |
|
|
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
|
Posted: Thu 12 Nov '20 11:11 Post subject: |
|
|
Okay, thank you. |
|
Back to top |
|