EN
apache2 - testing if the VirtualHost is working
5 points
In this short article we would like to show how to check with curl
command if VirtualHost
is working correctly under Apache2 server.
Presented approach uses fact, if we have set many domains under one apache2 instance, we can send Host: my-domain.com
header that switches between domains under same server.
Note: check if
curl
is installed - you can use Windows or Linux Bash.
Run following command:
xxxxxxxxxx
1
curl '88.77.44.200' -H 'Host: my-domain.com' --compressed --insecure
Where:
88.77.44.200
should be replaced with your server ip address of machine with apache2,my-domain.com
should be replaced with domain configured inVirtualHost
.
Example output:
xxxxxxxxxx
1
% Total % Received % Xferd Average Speed Time Time Time Current
2
Dload Upload Total Spent Left Speed
3
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
4
5
6
<html>
7
<head>
8
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
9
<meta name="viewport" content="width=device-width, initial-scale=0.8, user-scalable=yes">
10
<title>Welcome on my page!</title>
11
12
...
Example /etc/apache2/sites-enabled/my-domain.com.conf
file content:
xxxxxxxxxx
1
<VirtualHost *:80>
2
ServerName my-domain.com
3
ProxyPreserveHost On
4
ProxyPass / http://127.0.0.1:8080/
5
ProxyPassReverse / http://127.0.0.1:8080/
6
</VirtualHost>