This repository contains frontend code for REDIAL
- Website: http://drugcentral.org/Redial
To run the application on your system, you need docker installed. You can run the app directly using docker by using the following command to do so
docker-compose -f docker-compose.yml --env-file .env.dev up --build -d
You can leave out -d
flag if you do not wish to run in detached mode
Go to http://0.0.0.0:80/ to check out the running server.
Note: You will need to create a new file .env.dev, which will contain environment variables (secret keys) for the project
SERVER_HOST=0.0.0.0:80
With the current AWS structure, we need to create an EC2 instance to run the docker container, and Route 53 to use DNS service.
After the EC2 is created, connect using the SSH client option (you need the .pem
file generated during EC2 initialization to connect using this option), or directly using the console
On successful connection, install docker, docker-compose and git on the instance using the following commands
Note: If you want to allow traffic over HTTP and HTTPS, make sure to check the options under Network Settings while creating EC2 instance.
sudo yum install docker
sudo service docker start
sudo usermod -a -G docker ec2-user
Use the command below to auto start docker
sudo chkconfig docker on
sudo yum install -y git
sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
Finally, after the required installations, reboot the instance by using
sudo reboot
This will reboot the EC2 instance, thereby closing the shell connection that was established. In order to perform the further steps, connect to the instance again.
Now that Git and Docker are installed on the EC2 instance, clone the repository using
git clone <repository URL>
Change the current directory to access the files in the repository cloned in the step above.
To run the server on production, simply run the bash script called deploy.sh using
bash deploy.sh
The above command will spin up the docker containers and attach them to the ports exposed by the container.
The server can now be accessed using the public IP of the EC2 instance.
Note: You will only be able to access the server over HTTP, make sure to use http in URL instead of https
To request a domain and add SSL certificate to the server, you need to follow these steps:-
- Requesting domain from Route53
- Requesting certificate from ACM
- Creating CloudFront distribution ID to link to EC2 instance
- Adding Alias name records to Route53
- Verifying certificates from EC2 instance
Go to Route53 in AWS console, under Registered domains register a new domain name that you want to use with your server (you need to check if the domain is available, if not, choose a different domain name).
To connect a domain name and add SSL certificates to access the server over HTTPS, you need to request a public certificate from AWS Certificate Manager (ACM). Enter fully qualified domain name that you wish to request.
Note: Click on Add another name to this certificate and make sure to add the domain name prefixed with
www.
After requesting the certificate, you need to add CNAME records to Route53 and wait for validation of certificate by Amazon.
On the AWS console, open CloudFront service, and create new distribution.
Configuration for distribution:
- Origin domain - Public IPv4 DNS of EC2 instance which needs to be linked to the domain name
- Name - Distribution name
- Viewer protocol policy - Redirect HTTP to HTTPS
- Allowed HTTP methods - GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE
- Cache policy - CachingDisabled
- Origin request policy - AllViewer
- Alternate domain name (CNAME) - Add two records, (a) DOMAIN_NAME (b) www.DOMAIN_NAME
And finally link the requested certificate from ACM to the distribution under Custom SSL certificate, and create distribution.
Go to Route53 entry of your domain name, and add two A records, which need to be alias to the created CloudFront distribution.
First record with empty record name, and the second record name will be www
After linking the instance and certificate using the distribution, connect to the EC2 instance either using shell access, or using the console
-
Make sure
nginx
is installed, or usesudo yum install nginx
to install
-
Install certbot
sudo python3 -m venv /opt/certbot
sudo /opt/certbot/bin/pip install --upgrade pip
sudo /opt/certbot/bin/pip install certbot certbot-nginx
sudo ln -s /opt/certbot/bin/certbot /usr/bin/certbot
-
Request certificate installation using
certbot certonly --nginx
and enter the details on the prompt
Once validation is complete, the certificates have been installed, and network traffic will work over HTTPS.