Testing a website from server before DNS switch via SSH Tunneling

This is a continuation to the blob I previously posted. Since then I have found another way of testing a site without switching the DNS.

What this approach does is, it assigns the port from the server (that you are migrating your site to) to a port on your local machine. And you can add your domain name on the hosts file with the 127.0.0.1 IP and you should see the site loading on your browser only. More details below:

Requirement: You need to have ssh access to your server obviously and have a tool on your local development PC that lets you ssh via command line.

  • Open the terminal and type the command below on your local PC.
ssh -L localPort:remoteServerName:remotePort username@remoteServerName

localPort : is the port where you want the application to be mimicing on your local pc.

remoteServerName: Hostname of the remote server where your application is being setup and migrated.

remotePort: The port number on the Remote Host server where you application is being servers by Apache or other web server.

username: The user name that you will use to ssh to the remote server.
  • After doing the above, update your hosts file on the local development pc to point the domain name you are trying to test to 127.0.0.1 . example : 127.0.0.1 www.testsite.com
  • If you chose port 80 or 443 for localPort, then type the domain https://www.testsite.com on your browser and it should show the site that is running on the remoteServerName:remotePort.

You should now be able to test all your sites running on your servers using the above method via browser unlike the curl method mentioned in my previous port.


Learning a little bit of system administration

I am learning usage of VMware to setup multiple servers on a single physical system.

After working on web development on a localhost and pushing changes to a staging then production server for a long time, now I am going to learn how to setup a developer server, staging server,  production server, database servers and other required servers on a given number of resources optimally using Virtual Machines.

Currently at work we use VMware on host systems  and run multiple servers on the same system making optimal usage of the resources. First thing I am doing is reading up on technical information about VMware here. Then I will be learning how to set ip addresses within a network and assign DNS to them. Then I will install a linux server on  one of the VM clients and setup a server etc..

I will be doing all this in my laptop and from now on instead of installing linux on a seperate partition as I have been doing for years, I will be installing it on a VM host on my laptop and will operate them from my windows like I always wanted to do (without rebooting the system).

I have played around with these virtual pc stuff in my school days but never went too deep into it. This is the time when I need to go into it deep. I am very excited to experiment with all this. I should have learned all these earlier but never mind. Its never too late to learn 🙂