- Lab
- 
                        Libraries: If you want this lab, consider one of these libraries.
- Cloud
- Security
 
            
        Configure a Back End for a Web Application
In this lab, we set up a back end for the existing front end of a web application. We do this by creating a proper folder that will hold the code of our back end. Then we proceed to create a systemd file which will be used to start, stop, and get the status of this process at any given time. In addition to this, we will daemonize the process in this manner. In general, we might ask ourselves what does this have to do with Apache web server? If we have a front-end web application served to us via the Apache web server, there likely exists a back end that will fetch the content to be presented by the front end. In addition to this, Apache web server doesn't necessarily need to be configured to serve websites. It can also serve as a reverse proxy for various API's and serve pretty much any content imaginable. Therefore, it stands to reason we should know how to configure Apache web server to interact not only with the user, website, or front end, but the back end as well.
 
            
        Lab Info
Table of Contents
- 
                
                Challenge Create a New Directory for the Back End and Move `app.py` to the Newly-Created Directorymkdir /home/cloud_user/Backendsudo mv /home/cloud_user/HardeningApache-master/app.py /home/cloud_user/Backend/sudo chown cloud_user:cloud_user /home/cloud_user/Backend/app.py
- 
                
                Challenge Install Dependencies: python36.x86_64, python36-devel.x86_64, "Development Tools", python36-pip, Flask, flask-cors, psutil, and tcpdump, then Open Port 65535 with `firewalld`sudo yum install epel-releasesudo yum updatesudo yum install python36sudo yum install python36-develsudo yum groupinstall "Development Tools"sudo yum install python36-pipln -s /usr/local/bin/pip3 /usr/bin/pip3sudo pip3 install Flasksudo pip3 install flask-corssudo pip3 install psutilsudo yum install tcpdumpsudo firewall-cmd --permanent --add-port=65535/tcpsudo firewall-cmd --reload
- 
                
                Challenge Create a systemd File for Our Back End Called "flaskapp.service" in `/etc/systemd/system/`sudo vim /etc/systemd/system/flaskapp.service[Unit] Description=API_Backend After=network.target [Service] User=root Group=root WorkingDirectory=/home/cloud_user/Backend Environment=FLASK_ENV=development Environment=FLASK_APP=/home/cloud_user/Backend/app.py ExecStart=/usr/local/bin/flask run -h 0.0.0.0 -p 65535 Restart=always [Install] WantedBy=multi-user.targetSave and Closesudo systemctl daemon-reloadsudo systemctl start flaskappsudo systemctl enable flaskapp
- 
                
                Challenge Configure the Front End to Be Able to Access the Back End and Test If the Back End Worksvim /var/www/html/index.htmlInsert the Server Public IP address herevar base_url = 'http://<Server_Public_IP>:65535';Save and closeESC :wq ENTERTest if it workscurl http://<Server_Public_IP>:65535/log_messages
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.
 
           
                 
                