Languages
[Edit]
EN

apache2 - testing if the VirtualHost is working

5 points
Created by:
LionRanger
461

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:

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 in VirtualHost.

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>
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Apache2

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join