I was working on a project and it required some firewall ports to be opened. The team asked; how can we test the firewall rules are working correctly? There are different ways to test the firewall rules but here is a quick way to test your firewall. A web server with a simple text page. This tutorial will help you install and configure an Ubuntu server with Apache 2.
Steps to configure your web server.
1. Download the latest version of Ubuntu Server http://www.ubuntu.com/download/server
2. Follow the installation prompts to install Ubuntu Server
3. In the packages selection, select OpenSSH server and LAMP
4. After your server reboots, connect to the server via SSH.
5. Edit /etc/apache2/ports.conf add the entry for your web test. Your ports.conf will look similar to this one. Example vi /etc/apache2/ports.conf
6. Change directory to /etc/apache2/sites-enabled and create a new site for each port you want to test firewall connectivity. In my example I wanted to test 80, 443 and 8443 so I created one file for each different site. Use your favorite editor to edit the configuration. Example : vi 001.conf
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/443
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
7. After you finish with all the files, restart the apache web server: service apache2 restart
8. Create an Index file for your different websites. Example vi /var/www/html/index.html
Text For index HTML page.
<html>
<head>
<title></title>
</head>
<body>
<p>
Demo Page for Testing Port 80</p>
<p>
<p>
Author: Carlos Vargas</p>
<p>
HDS Rocks
</body>
</html>
9. Open your favorite Internet browser and navigate to your pages or test your firewall ports
In my example I needed to test port 80, 443, and 8443
http://<youripaddress> (this is the default for port 80)
http://<youripaddress>:443 (this will open the site in port 443)
http://<youripaddress>:8443 (this will open your website in port 8443)