Implementing OWNCLOUD Solution on AWS
Section 1 : Architecture Blueprint
Section 2. Implementation Plan
- Implement 2 different subnets (one public and the other private) in a custom VPC called owncloud-vpc.
2. Install and configure MySQL database to run on the private subnet. This subnet should be associated with a security group that allows traffic to private subnet only from the public subnet.
3. The owncloud-app should be installed in public subnet and MUST be configured to access a new database called owncloud-db (created by you) in the private subnet.
4. Apache HTTP server should host ownCloud application in this subnet and must be configured with required PHP modules for ownCloud.
Section 3: OwnCloud VPC Creation
- Go to AWS VPC Dashboard and Create Custom VPC with the name OwnCloud-VPC.
2. Once the VPC is created check the CIDR Block is 10.0.0.0/16 and give the tag for reference to default route table of the custom VPC as OwnCloud-RT-Default
Section 4: Public Subnet Creation, Configuration of Internet Gateway, Route Table creation and Subnet association and Security group creation.
- Create a Public Subnet by the name OwnCloud-Public and CIDR block 10.0.1.0/24
2. Go to Internet Gateways option and click on Create Internet Gateway with the name OwnCloud -IGW and click create.
3. Once the Internet Gateway is created, go to actions and attach to Owncloud-VPC. Note the IGW Id that is created has the state “attached”.
4. Create Route Table for the Public Subnet by the name OwnCloud-RT-Public and associate it with Owncloud-VPC.
5. Once the Custom Route Owncloud-RT-Public is created, edit and add the route as Destination: 0.0.0.0/0 ; Target: owncloud-IGW ( Internet gateway ) and save the routes
6. Edit Subnet associations of Owncloud-RT-Public select the CIDR 10.0.1.0/24 associated with the public subnet and click save.
7. Create a new Security Group by the name OwnCloud-Public-SG, associate it with owncloud-VPC and click create.
8. Once the Security group Owncloud-Public-SG is created, selct the security group and click edit rules.
9. Add Inbound Rules to allow traffic for HTTP TCP Port 80, HTTPS TCP Port 443 and SSH TCP port 22.
Section 5: Private Subnet Creation, Configuration of NAT Instance, Route Table creation and Subnet association and Security group creation.
- Create a Private Subnet by the name OwnCloud-Private and CIDR block 10.0.2.0/24 and associate it with Owncloud-VPC.
2. Use the 7-step workflow to create a NAT instance T-2Micro in the public subnet using available AMI from AWS marketplace.
3. Name the Instance OwnCloud-NAT in the availability Zone us-east-1a
4. Select OwnCloud-NAT, select networking under actions and click on change Source/Dest check and click on disable. This is needed.
5. Create Route Table for the Private Subnet by the name OwnCloud-RT-Private and associate it with Owncloud-VPC.
6. Once the Custom Route Owncloud-RT-Private is created, edit and add the route as Destination: 0.0.0.0/0 ; Target : OwnCloud-NAT ( NAT gateway ) and save the routes.
7. Edit Subnet associations of Owncloud-RT-Private select the CIDR 10.0.2.0/24 associated with the public subnet and click save.
8. Create a new Security Group by the name OwnCloud-Private-SG, associate it with owncloud-VPC and click create.
9. Add Inbound Rules to allow traffic for type SSH on TCP Port 22, MYSQL/Aurora on TCP Port 3306 and select source as the security group
sg-02fa49815284b4c21 (security group of the public subnet)
10. Create another security Group and call it OwnCloud-NAT-SG and allow Type HTTP on TCP Port 80; SSH on Port 22; HTTPS on Port 443 and source is the Private Subnet range 10.0.2.0/24 [ This will allow communication between private and Public Subnet].
Section 6: Deploy Owncloud App Instance and Install Apache and PHP on Ubuntu 18.04.
- Create Ubuntu 18.04 instance using 7 steps workflow.
2. Open ports 80 and 22 using security group.
3. ssh to created instance.
4. Install apache web server using following commands
· sudo apt-get update
· sudo apt-get install apache2
5. Validate installation by accessing public ip of EC2 instance in browser.
6. Use the following commands to install php.
· sudo apt install php
· libapache2-mod-php php-mysql.
7. Make index.php as the default first load page 1.
· Edit /etc/apache2/mods-enabled/dir.conf file and make index.php as first access page.
· DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm 2.
8. Restart the web server — sudo systemctl restart apache2.
Section 7: Install OwnCloud on Ubuntu 18.04
1. Run following commands
· curl https://download.owncloud.org/download/repositories/10.0/Ubuntu_18.04/Release.key | sudo apt-key add — (Curl command did not work used “wget” instead and added Release. Key)
· echo ‘deb http://download.owncloud.org/download/repositories/10.0/Ubuntu_18.04/ /’ | sudo tee /etc/apt/sources.list.d/owncloud. List
· sudo apt update.
· sudo apt install php-bz2 php-curl php-gd php-imagick php-intl php-mbstring php-xml php-zip owncloud-files.
2. Change default site directory to owncloud files directory using sudo user 1. edit /etc/apache2/sites-enabled/000-default.conf; update directory root path to /var/www/owncloud.
3. Restart the server — sudo systemctl reload apache2.
4. Access the owncloud application using public ip of EC2 instance in browser.
http://3.92.204.88/index.php/login
Section 8: Install OwnCloud DB on MySQL and establish Owncloud to DB connection
- Install OwnCloud-DB instance in the same Availability Zone as OwnCloud-App to have least latency with the 7-step workflow.
2. Configure MySQL to get the connection established.
· mysql -u root -p
· CREATE DATABASE owncloud;
· GRANT ALL ON owncloud.* to ‘owncloud’@’10.0.1.247 IDENTIFIED BY ‘password’;
· FLUSH PRIVILEGES;
· exit
3. Configure OwnCloud after successful MySQL DB connection.
4. Configure OwnCloud after successful MySQL DB connection type 10.0.2.56 which is the IP address of the MySQL DB.
5. Uploaded files to validate the successful deployment of Owncloud-app .
Section 9: Cleaned up all Resources.
Section 10: Learnings and Observation
1. curl https://download.owncloud.org/download/repositories/10.0/Ubuntu_18.04/Release.key | sudo apt-key add — (Curl command did not work used “wget” instead and added Release. Key)
2. Had Issues with Apache Installation as the directory did not exist and owncloud url was not reachable via Public IP, (Had to reinstall the OwnCloud PHP modules to finally get this working.)
3. OwnCloud-App did not connect to MySQL instance and had to troubleshoot Finally had to give the elastic IP of OwnCloud-App to successfully authenticate remotely. GRANT ALL ON owncloud.* to ‘owncloud’@’10.0.1.247 IDENTIFIED BY ‘password’;
4. Had Issue with NAT instance deployed from the market place so connectivity to Internet took time to fix, Had to redeploy the NAT Instance and disable Source destination check.