Connect a domain to your project without SSL

Ankit Kumar Rajpoot
3 min readJun 5, 2020

--

In this article, we connect our domain to the project without SSL. This article specially for EC2, Ubuntu, and apache2. We will connect the GoDaddy domain with our react js project which is running on ec2 with ubuntu os.

We will do it step by step all steps are given below:-

Step 1:- Install Apache2

Install apache2(Apache is HTTP Server) in your operating system but in this article, we are using ubuntu so we will install through command. All commands are given below.

sudo apt-get update
sudo apt-get install apache2
sudo ufw app list
sudo ufw allow ‘Apache Full’
sudo ufw status // Status will be inactive.
sudo systemctl status apache2 // Apache server will be Active.

Step 2:- Check Apache Server

After installation, you will verify that Apache is working fine or not. So for testing, you will search your IP in the browser then you will see an apache default page means it’s working fine.

Step 4:- Connect Domain

Firstly connect your server with SSH or whatever you want then go to the site-available directory and update 000-default.conf file.

$ cd /etc/apache2/sites-available
$ ls
000-default.conf default-ssl.conf
$ sudo nano 000-default.conf

Update 000-default.conf file like this.

<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName www.example.com # Put your domain
ServerAlias example.com
ProxyPass / http://localhost:4000/ # Put your port
ProxyPassReverse / http://localhost:4000/ # Put your port
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Check the same file 000-default.conf at /etc/apache2/sites-enabled updated or not, if not then update manually like above.

Reload the server via given command.

$ service apache2 reload

After reloading everything is fine then you can run your project through the domain.

And after reloading you find these two errors:-

1. Invalid command ‘ProxyPreserveHost’, perhaps misspelled or defined by a module not included in the server configuration Action ‘configtest’ failed.

2. Job for apache2.service failed because the control process exited with error code. See “systemctl status apache2.service” and “journalctl -xe” for details.

Then you will have to start some services

sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_ajp
sudo a2enmod proxy_balancer
sudo a2enmod proxy_connect
sudo a2enmod proxy_html
sudo a2enmod ssl
apachectl configtest # Check Syntax erorr
sudo service apache2 restart
sudo systemctl status apache2

You can see error through apachectl configtest command.

Some Commands for manage Apache Process

$ sudo systemctl stop apache2        // Stop Apache Server
$ sudo systemctl start apache2 // Start Apache Server
$ sudo systemctl restart apache2 // Restart Apache Server
$ sudo systemctl reload apache2 // Reload Apache Server
$ sudo systemctl disable apache2 // Disable Auto Start Server
$ sudo systemctl enable apache2 // Enable Auto Start Server

Now everything is fine you can run your project through domain without SSL. But your domain will sow insecure.

--

--

Ankit Kumar Rajpoot
Ankit Kumar Rajpoot

Written by Ankit Kumar Rajpoot

I’m a MERN Developer. ( Redux | AWS | Python ) I enjoy taking on new things, building skills, and sharing what I’ve learned.

No responses yet