Web Server with old PC, XAMPP, Domain Name

Here I am sharing how I made a DIY Production Web Server with old PC, XAMPP, Mikrotik router Domain Name. This can be useful to host your website, real time web application and IoT services. What you will need are XAMPP, a domain name, static external IP, a Mikrotik router or switch and a PC/laptop. In this guide, I am using leased static IP obtained from a ISP(Internet Service Provider). So to follow this guide you need static IP. If you have dynamic IP assigned by your ISP and you want to set the web server set up at home for free then tunneling might work for you.

network diagram webserver

 

XAMPP Apache Web Server

To build the Web Server, I utilized old laptop(PC) and installed XAMPP on it to create a Apache based webserver. I installed XAMPP version 8.0.28 / PHP 8.0.28.  I configured it to use virtual host, enabled the SSL connection For this there are few configuration we have to make. 

A. The first thing we have to check is whether the virtual host feature is enabled or not. 

a.Open the file httpd.conf located in your XAMPP installation directory which is usually located at

C:\xampp\apache\conf\httpd.conf.

in windows operating system. 

b. Check whether the following line is commented with # or not. If it is, remove the # symbol.

Include conf/extra/httpd-vhosts.conf 

B. Next we need to enable the SSL connection feature which can be done by removing the # symbol infront of the following line located in the same file httpd.conf.

LoadModule ssl_module modules/mod_ssl.so


 Also we need to comment out the following line.

Include conf/extra/httpd-ssl.conf

These are done for our site to work with https protocol.

Website

I download a free website for testing purpose and placed the website files within the htdocs folder:

C:\xampp\htdocs\dm_website

For test purpose you can simple use a text editor and write a simple webpage and save it as .html file with some name like index.html.

Domain Name

 I bought a cheap domain name dm.online(another name used for example purpose) at namecheap.com. There you need to set the IP address of your webserver. To do this go to the Manage >Advanced DNS and add a A record with Host @ and for value write your static IP address such as 50.50.50.94. I have set TTL to automatic.

Namecheap static routing

Virtual Host

 Then I have configured the virtual host. The virtual host httpd-vhosts.conf file in XAMPP is located in:

D:\xampp\apache\conf\extra

Open this file and add the following:

#Configuration example A:

<VirtualHost *:80>
    DocumentRoot "C:\xampp\htdocs\dm_website"
    ServerName dm.online
    ServerAlias www.dm.online
</VirtualHost>

As already mentioned above, the website domain name is dm.online and its files is inside the folder C:\xampp\htdocs\dm_website.

This is the simplest way of using virtual host in xampp apache. If you wish you can add additional settings. One way is to use directory in virtual host. An example is shown below.

#Configuration example B:

<VirtualHost *:80>
    ServerName dm.online
    DocumentRoot "C:\xampp\htdocs\dm_website"
    <Directory "C:\xampp\htdocs\dm_website">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>


virtual host

Mikrotik Router Configuration

On the Mikrotik router, I have to setup several things. First let me set the scenario first. The ISP has gave me the following IP, network address and gateway IP: 

IP:50.50.50.94/30

Network:50.50.50.93

Gateway:50.50.50.92. 

I have a bridge setup bridge1 with IP address 10.10.0.1/24 and network 10.10.0.0 with the bridge1 ports being ether2 to ether5. I also have DHCP server dhcp1 with IP address range 10.10.0.1/24 and gateway 10.10.0.1.

Web Server static IP

The web server PC is connected to ether2 port of the router with a LAN cable. internal IP  set it as an static IP. The PC/Laptop(webserver) was given dhcp IP of 10.10.0.100 and was made a static IP by clicking on Make Static button from the IP>DHCP server > Leases menu.

Mikrotik make IP static IP

 TPC port 80 and 433

The next thing I had to do is to open the http and https TCP ports 80 and 443 on ether1 port of the router. To do this we have to set NAT rule. For this go to the Firewall setting under IP >Firewall. Click on the NAT menu and click on the + sign to add a new NAT rule.

 For opening the port 443 on ether1 port of the Mikrotik router and set the destination web server internal IP address to forward traffic select Chain as dstnat, select the protocol tcp, and select the ether1 port as the Int.Interface. Then form the Action tab, select the dst-nat as the Action, enter the internal IP address like 10.10.10.100 of the web-server.

open port in mikrotik router

Follow the same as above for opening the port 443 on ether1 port of the router and set the destination web server internal IP address to forward traffic to.

open port in mikrotik router

Mikrotik Switch Configuration

Bridge

A bridge called bridge1 is created in the Mirkrotik switch which includes ether1 to ether6. The bridge1 is assigned IP address of 192.168.0.1/24 with gateway 192.168.0.1.

DHCP Client

The switch is configured as a DHCP client to obtain IP address from the router. The DHCP client interface is bridge1.  

Mikrotik DHCP client

There is nothing else configured else than these.

So in this way I created a webserver using XAMPP, Mikrotik router and switches. If you have any suggestion or correction, I would be happy to hear them. 


Post a Comment

Previous Post Next Post