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
curlis installed - you can use Windows or Linux Bash.
Run following command:
curl '88.77.44.200' -H 'Host: my-domain.com' --compressed --insecure
Where:
88.77.44.200should be replaced with your server ip address of machine with apache2,my-domain.comshould be replaced with domain configured inVirtualHost.
Example output:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=0.8, user-scalable=yes">
<title>Welcome on my page!</title>
...
Apache2 configuration
Example /etc/apache2/sites-enabled/my-domain.com.conf file content:
<VirtualHost *:80>
ServerName my-domain.com
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
</VirtualHost>