<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ofem John on Medium]]></title>
        <description><![CDATA[Stories by Ofem John on Medium]]></description>
        <link>https://medium.com/@ofem.john?source=rss-a340d0084396------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*OvihvZj2ivLZQSb6</url>
            <title>Stories by Ofem John on Medium</title>
            <link>https://medium.com/@ofem.john?source=rss-a340d0084396------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 02:57:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ofem.john/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Title: Deploying a React Flask App with React Router, Gunicorn, and SSL Certificate on Nginx]]></title>
            <link>https://medium.com/@ofem.john/title-deploying-a-react-flask-app-with-react-router-gunicorn-and-ssl-certificate-on-nginx-2ca2cce08577?source=rss-a340d0084396------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ca2cce08577</guid>
            <dc:creator><![CDATA[Ofem John]]></dc:creator>
            <pubDate>Tue, 12 Sep 2023 01:44:11 GMT</pubDate>
            <atom:updated>2023-09-13T19:22:58.652Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s digital age, deploying a web application securely and efficiently is a fundamental skill for any developer. This blog post will take you on a journey through deploying a React Flask app, complete with a React Router, Gunicorn, and an SSL certificate for added security. We’ll delve into the step-by-step process of setting up your web application on a Digital Ocean server running Ubuntu 22.04, utilizing Nginx as the web server. By the end of this guide, you’ll have a fully functioning, secure, and performant web application ready to shine on the internet.</p><p>Prerequisites</p><p>Before diving into the deployment process, ensure you have the following: A fully functional Flask backend that serves your API endpoints. A React frontend application with a React Router configured for client-side routing. Access to a Digital Ocean droplet or another server running Ubuntu 22.04. You should have SSH access to this server. A registered domain name (e.g., johnteacher.tech) and access to its DNS settings for configuring SSL. Basic knowledge of working with terminal commands and server administration. These prerequisites will lay the foundation for deploying your React Flask app with Nginx and SSL certificate.</p><p>Transferring Your React and Flask Code to Your Server Using Secure Copy (SCP)</p><pre>cd /home/project-folder<br># Compress your Flask /api folder<br>tar -czvf api.tar.gz api<br># Securely copy your compressed /api folder to your remote server.<br># Make sure you create a receiving folder on your server (/react-flask)<br>scp -r /home/project-folder/api.tar.gz username@server-ip:/react-flask<br># Create an optimized build version of your React app<br>cd /client npm run build<br># Creates a build folder containing your optimized static files<br># copy the build folder to your remote server<br>scp -r /home/project-folder/client/build/* username@server-ip:/react-flask<br></pre><p>Accessing Your Remote Server for Deployment<br>After you have successfully gained access to your server the first thing to do is to uncompress your Flask API backend folder.</p><pre>tar -xzvf api.tar.gz<br># install nodjs and npm if you dont already have it<br>sudo apt install nodejs npm </pre><p>Creating a Python Virtual Environment</p><pre>cd /api python3 -m venv myvirtualenv<br># activate the environment created<br>source myvirtualenv/bin/activate<br># install pip<br>(myvirtualenv) $ sudo apt update<br>(myvirtualenv) $ sudo apt install python3-pip<br>(myvirtualenv) $ pip3 - version<br><br># install your requirments.txt file for your project dependencies<br>(myvirtualenv) $ pip3 install requirements.txt<br><br># install flask and gunicorn<br>(myvirtualenv) $ pip3 install gunicorn flask<br>(myvirtualenv) $ sudo ufw allow 5000<br># run your flask app locally for testing<br>(myvirtualenv) $ python3 app.py<br><br><br></pre><pre>Output * Serving Flask app &quot;app.py&quot; (lazy loading)<br>* Environment: production WARNING: <br>Do not use the development server in a production environment.<br>Use a production WSGI server instead.<br>* Debug mode: off * Running on http://0.0.0.0:5000/<br> (Press CTRL+C to quit) <br># Visit your server&#39;s IP address followed by :5000 in your web browser: http://your_server_ip:5000 Create a wsgi.py to run your flask app with Gunicorn</pre><pre>(myvirtualenv) $ vim /home/project-folder/api/wsgi.py<br># put the line of code below inside the wsgi.py file<br><br><br><br>from app import app <br>if __name__ == &quot;__main__&quot;: <br>  app.run()</pre><p>Configuring Gunicorn:</p><p>Your application is now written with an entry point established. You can now move on to configuring Gunicorn. Before moving on, check that Gunicorn can serve the application correctly.</p><pre>(myvirtualenv) $ cd /api<br>(myvirtualenv) $ gunicorn - bind 0.0.0.0:5000 wsgi:app<br></pre><p>Visit your server’s IP address with :5000 appended to the end in your web browser again: <a href="http://your_server_ip:5000/">http://your_server_ip:5000</a></p><pre>(myvirtualenv) $ deactivate</pre><p>Next, create the systemd service unit file. Creating a systemd unit file will allow Ubuntu’s init system to automatically start Gunicorn and serve the Flask application whenever the server boots. Create a unit file ending in .service within the /etc/systemd/system directory to begin:</p><pre>sudo vim /etc/systemd/system/reactflask.service</pre><pre>[Unit]<br>Description=Gunicorn instance to serve my project<br>After=network.target<br><br>[Service]<br>User=username<br>Group=www-data<br>WorkingDirectory=/react-flask/api<br>Environment=&quot;PATH=/react-flask/api/venv/bin&quot;<br>ExecStart=/react-flask/api/venv/bin/gunicorn - workers 3 - bind unix:reactflask.sock -m 007 wsgi:app<br><br>[Install]<br>WantedBy=multi-user.target</pre><pre>sudo systemctl start reactflask<br>sudo systemctl enable reactflask<br>sudo systemctl status reactflask</pre><pre>Output<br>● myproject.service - Gunicorn instance to serve myproject<br>     Loaded: loaded (/etc/systemd/system/reactflask.service; enabled; vendor preset: enabled)<br>     Active: active (running) since Tue 2022-05-10 19:40:41 UTC; 9s ago<br>   Main PID: 17300 (gunicorn)<br>      Tasks: 4 (limit: 2327)<br>     Memory: 56.0M<br>        CPU: 514ms<br>     CGroup: /system.slice/myproject.service<br>             ├─17300 /react-flask/api/myvirtualenv/bin/python3 /react-flask/api/myvirtualenv/bin/gunicorn - workers 3 - bind unix:reactflask.sock -m 007 wsgi:app<br>             ├─17301 /react-flask/api/myvirtualenv/bin/python3 /react-flask/api/myvirtualenv/bin/gunicorn - workers 3 - bind unix:reactflask.sock -m 007 wsgi:app<br>             ├─17302 /react-flask/api/myvirtualenv/bin/python3 /react-flask/api/myvirtualenv/bin/gunicorn - workers 3 - bind unix:reactflask.sock -m 007 wsgi:app<br>             └─17303 /react-flask/api/myvirtualenv/bin/python3 /react-flask/api/myvirtualenv/bin/bin/gunicorn - workers 3 - bind unix:reactflask.sock -m 007 wsgi:app<br><br>May 10 19:40:41 r systemd[1]: Started Gunicorn instance to serve myproject.<br>. . .</pre><p>At this point, If you see any errors, be sure to resolve them before continuing with the tutorial.<br>Configuring Nginx to Proxy Requests</p><pre># locate nginx default configuration file and configure nginx to serve you build folder<br>sudo vim /etc/nginx/sites-available/default</pre><p># add this configurations server</p><pre>server {<br> server_name johnteacher.tech www.johnteacher.tech;<br><br> location / {<br>  root /jobhub/build;<br>  index index.html;<br>  rewrite ^([^/]+)$ /$1/index.html;<br>  try_files $uri $uri/ = 404;<br>  error_page 404 /index.html;<br> }<br><br>    location /api {<br>               include proxy_params;<br>               proxy_pass http://unix:/jobhub/api/job-hub.sock;<br>        }<br>}</pre><p>To enable the Nginx server block configuration you’ve just created, link the file to the sites-enabled directory:</p><pre>sudo ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled<br># check to see if any errors with your nginx configurations<br>sudo nginx -t</pre><p>If this returns without indicating any issues, restart the Nginx process to read the new configuration:</p><pre>sudo systemctl restart nginx<br>sudo ufw delete allow 5000<br>sudo ufw allow &#39;Nginx Full&#39;<br>sudo chmod 755 /react-flask</pre><p>You should now be able to navigate to your server’s domain name in your web browser:</p><pre>http://yourdomain</pre><p>If you encounter any errors, try checking the following:</p><pre>sudo less /var/log/nginx/error.log # checks the Nginx error logs.<br><br>sudo less /var/log/nginx/access.log # checks the Nginx access logs.<br><br>sudo journalctl -u nginx # checks the Nginx process logs.<br><br>sudo journalctl -u myproject # checks your Flask app&#39;s Gunicorn logs.</pre><p>Securing the Application</p><pre>sudo apt install python3-certbot-nginx Certbot<br><br>sudo certbot --nginx -d your_domain -d www.your_domain</pre><p>This runs certbot with the --nginx plugin, using -d to specify the names we’d like the certificate to be valid for.</p><p>If this is your first time running certbot, you will be prompted to enter an email address and agree to the terms of service. After doing so, certbot will communicate with the Let’s Encrypt server, then run a challenge to verify that you control the domain you’re requesting a certificate for.</p><p>If that’s successful, certbot will ask how you’d like to configure your HTTPS settings:</p><pre>Output<br>Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.<br>-------------------------------------------------------------------------------<br>1: No redirect - Make no further changes to the webserver configuration.<br>2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for<br>new sites, or if you&#39;re confident your site works on HTTPS. You can undo this<br>change by editing your web server&#39;s configuration.<br>-------------------------------------------------------------------------------<br>Select the appropriate number [1-2] then [enter] (press &#39;c&#39; to cancel):</pre><p>Select your choice then hit ENTER. The configuration will be updated, and Nginx will reload to pick up the new settings. certbot will wrap up with a message telling you the process was successful and where your certificates are stored:</p><pre>Output<br>IMPORTANT NOTES:<br> - Congratulations! Your certificate and chain have been saved at:<br>   /etc/letsencrypt/live/your_domain/fullchain.pem<br>   Your key file has been saved at:<br>   /etc/letsencrypt/live/your_domain/privkey.pem<br>   Your cert will expire on 2020-08-18. To obtain a new or tweaked<br>   version of this certificate in the future, simply run certbot again<br>   with the &quot;certonly&quot; option. To non-interactively renew *all* of<br>   your certificates, run &quot;certbot renew&quot;<br> - Your account credentials have been saved in your Certbot<br>   configuration directory at /etc/letsencrypt. You should make a<br>   secure backup of this folder now. This configuration directory will<br>   also contain certificates and private keys obtained by Certbot so<br>   making regular backups of this folder is ideal.<br> - If you like Certbot, please consider supporting our work by:<br><br>   Donating to ISRG / Let&#39;s Encrypt:   https://letsencrypt.org/donate<br>   Donating to EFF:                    https://eff.org/donate-le</pre><p>If you followed the Nginx installation instructions in the prerequisites, you will no longer need the redundant HTTP profile allowance:</p><pre>sudo ufw delete allow &#39;Nginx HTTP&#39;</pre><p>To verify the configuration, navigate once again to your domain, using <a href="https://:">https://:</a></p><pre>https://your_domain</pre><p>You should see your application output once again, along with your browser’s security indicator, which should indicate that the site is secured.</p><h3>Conclusion</h3><p>Congratulations! You’ve successfully deployed your React Flask web application on an Ubuntu 22.04 server with Nginx, Gunicorn, and an SSL certificate. This journey has taken you through the essential steps, from transferring your code to configuring the server and securing it with SSL.</p><p>By following this guide, you’ve learned how to:</p><ol><li>Transfer Your Code: Use Secure Copy (SCP) to move your React and Flask code to your server.</li><li>Set Up Your Flask Backend: Create a Python virtual environment, install dependencies, and configure Gunicorn to serve your Flask app.</li><li>Configure Nginx: Set up Nginx to proxy requests to your React frontend and Flask backend, enabling your app to run smoothly.</li><li>Secure Your Application: Obtain an SSL certificate using Certbot to encrypt data transmission and enhance security.</li></ol><p>Now, your web application is not only secure but also ready to impress users on the internet. As you continue to develop and improve your project, remember that maintaining a secure and efficient deployment is essential for a successful online presence.</p><p><em>I</em> hope this guide has been a valuable resource for your deployment journey. If you encounter any challenges or want to explore further, feel free to dive deeper into each topic or seek additional resources to enhance your skills. Happy coding and deploying!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ca2cce08577" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Post-Mortem Report: HAProxy Load Balancer Server Outage]]></title>
            <link>https://medium.com/@ofem.john/post-mortem-report-haproxy-load-balancer-server-outage-850da875d8b2?source=rss-a340d0084396------2</link>
            <guid isPermaLink="false">https://medium.com/p/850da875d8b2</guid>
            <dc:creator><![CDATA[Ofem John]]></dc:creator>
            <pubDate>Fri, 03 Feb 2023 11:01:41 GMT</pubDate>
            <atom:updated>2023-02-03T11:01:41.500Z</atom:updated>
            <content:encoded><![CDATA[<p>Date: 18/01/2023</p><h3>Incident Summary:</h3><p>On January 18, 2023, the HAProxy load balancer server experienced an outage, causing an interruption in service. The exact cause of the server loss is unknown, but it is believed to be due to a hardware failure.</p><h3>Timeline of Events:</h3><ul><li>12:15 pm: HAProxy load balancer server went down</li><li>12:20 pm: I was notified by a user</li><li>12:25: A new server was spun up and the saved server configurations scripts were used to reconfigure the server</li><li>12:40: The new HAProxy server was successfully configured and brought online, restoring service</li></ul><h3>Root Cause Analysis:</h3><p>The root cause of the incident was a hardware failure that led to the loss of the HAProxy load balancer server. The exact cause of the failure is unknown, but it is being investigated.</p><h3>Corrective Actions:</h3><p>A new server was spun up and reconfigured using the saved server configurations scripts, restoring service as quickly as possible. Regular backups of server configurations will be implemented to ensure that configurations can be easily restored in the event of a future server loss. The health of all servers will be monitored more closely to detect and address issues before they become critical.</p><h3>Conclusion:</h3><p>The HAProxy load balancer server outage caused an interruption in service, but the issue was quickly resolved by spinning up a new server and reconfiguring it using saved server configurations scripts. The root cause of the incident is unknown, but it is being investigated and steps have been taken to prevent similar incidents from happening in the future. The team will continue to monitor the health of all servers using a data-dog monitoring tool and regularly backup configurations to ensure the best possible uptime for the systems.</p><p>Signed by: [John Ofem] Software Engineering Student, ALX</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=850da875d8b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Have you ever considered what occurs when you type a website address (such as www.google.com)]]></title>
            <link>https://medium.com/@ofem.john/have-you-ever-considered-what-occurs-when-you-type-a-website-address-such-as-www-google-com-99ecc3eaca5b?source=rss-a340d0084396------2</link>
            <guid isPermaLink="false">https://medium.com/p/99ecc3eaca5b</guid>
            <dc:creator><![CDATA[Ofem John]]></dc:creator>
            <pubDate>Sun, 08 Jan 2023 18:10:44 GMT</pubDate>
            <atom:updated>2023-01-08T18:10:44.719Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever considered what occurs when you type a website address (such as <a href="http://www.google.com/">www.google.com</a>) into your browser and press Enter? LET’S DETERMINE.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V4LcnHu0Q6qMOCB_Bti30A.png" /></figure><p>The Google website is requested when you enter “<a href="https://www.google.com/">https://www.google.com</a>&quot; into your browser and hit Enter. But have you ever paused to consider what goes on in the background to fulfill this request? I think this is one activity that we have all done, in some way, and it only takes a few seconds for this request to result in the responses we want.</p><ul><li>DNS request: Converting the domain name you entered into your browser (<a href="http://www.google.com/">www.google.com</a>) into an IP address that computers can comprehend is the first step in visiting a website. DNS resolution is the term for this procedure. Your computer sends a request to a DNS server when you want to access a website, which then finds the IP address associated with the domain name and transmits it back to your computer. Although every domain name has been assigned an IP address, which is also the real address, the domain name system was formed because people find it easier to identify and remember names than numbers.</li><li>TCP/IP: Creating and maintaining connections between devices is the job of the transport layer protocol TCP, which also makes sure that data is transferred consistently and in the right order. To accomplish this, the data is split up into smaller packets, referred to as segments, and sent across the network. The sequence numbers contained in the packets are used by the receiving device to reassemble the data in the proper sequence. Therefore, the transport layer protocol TCP is in charge of accepting the request and ensuring that it gets to the address requested from when the user or client types the domain name in the browser. It also collects the necessary information requested from the client and sends the response back to the client. Data packets must be routed from one device to another via a network using the network layer protocol IP. This is accomplished by giving each network device a special IP address, which is then used to direct traffic to the appropriate device. All devices linked to the internet use TCP and IP together as their foundation to communicate with one another.</li><li>Firewall: The connection may go through a firewall before being formed. A firewall is a type of security system that regulates network traffic on the basis of pre-established security rules. Hardware-based, software-based, or a hybrid of the two are all possible for firewalls. A firewall’s main purpose is to prevent unwanted access to a network or device. By looking at incoming and outgoing traffic and permitting or blocking it in accordance with a set of rules, it accomplishes this. These guidelines may be determined by a number of factors, including the source or destination of the traffic, its nature, or the port being utilized. Firewalls can be set up to permit or deny traffic for a given IP address, port, or protocol.</li><li>HTTPS/SSL: The Secure Sockets Layer (SSL) protocol, currently known as Transport Layer Security, is used once the connection has been made between the server and the browser to start a secure, encrypted connection (TLS). By doing this, it is made sure that all information sent between the server and the browser is safe and cathesennot be intercepted by outside parties. A secure connection between the client and the server is created using HTTPS and either the Secure Sockets Layer (SSL) or Transport Layer Security (TLS) protocol. The data being communicated is encrypted using SSL/TLS using a combination of public and private keys. Data is encrypted with a public key and decrypted with a private key. This makes sure that the recipient intended can only read the data. Certificate authorities (CAs), who are dependable parties that confirm the legitimacy of a website’s owner, are the organizations that issue SSL/TLS certificates. An HTTPS-enabled website gives the client with its SSL/TLS certificate to prove its identity when the client starts a connection with the website. The client then compares the certificate to the list of trustworthy certificates maintained by the CA. The client and server create an encrypted connection if the certificate is legitimate. Online transactions like online banking and shopping frequently use HTTPS to safeguard the security and privacy of data being communicated over the internet.</li><li>Load-balancer: A load balancer may be used to pass the connection. In order to prevent any one server from becoming overloaded by uniformly dispersing the workload across numerous servers, load balancers contribute to increasing the performance, dependability, and scalability of a network. Load balancers come in two primary categories: software-based and hardware-based. Physical components that are deployed in a network act as hardware-based load balancers, which are in charge of spreading incoming traffic among a number of servers. The same job as a hardware-based load balancer is carried out by software-based load balancers, which are installed as virtual machines on a server. Different algorithms are used by load balancers to choose how to divide incoming traffic among the servers in their group. Round-robin, least connections, and least response time are a few examples of frequent algorithms. The load balancer keeps track of each server’s efficiency in its group and directs traffic to the most effective servers. The performance, dependability, and scalability of web applications, online stores, and other internet-based services are improved by the usage of load balancers, which are a crucial component of contemporary networks.</li><li>Web server: The connection is subsequently forwarded to a web server, a machine that stores and oversees a website’s data and content. Your web browser sends a request to the domain’s associated web server to obtain the requested web page when you type a domain name into the address bar and hit Enter. The task of storing and providing website material to users who request it falls on web servers. The common mechanism for data transmission over the internet, HTTP (Hypertext Transfer Protocol), is used by them to do this. A web server responds to an HTTP request from a client (such a web browser) by sending an HTTP response, which either contains the requested content or an error message if the request cannot be processed. Windows, Linux, and macOS are just a few of the operating systems that web servers can use. Additionally, they can be set up to handle a number of other programming languages, including PHP, Python, and Ruby, which are used to create dynamic websites that produce content on the fly. Web servers, which are used to host websites, web applications, and other internet-based services, are a crucial component of the internet.</li><li>Application server: An application server may receive a request from a web page if it needs to process data from a database or perform other operations. The system’s brain is the application server. It houses the entire application logic as well as the database on occasion. Django, Laravel, NodeJs, Flask and Java Spring are among the frequently used frameworks installed. Together with databases like MySQL, MongoDB, SQL Server, and Oracle, these are used. To access resources, such as user profiles and billing data stored in the database, the web server is continually in communication with the application server.</li><li>Database: The application server will send a request to a database server to retrieve the required data if a web page needs data from a database. The database server is a computer that organizes and manages data so that it may be updated and accessed with ease.</li></ul><p>Following the completion of all these procedures, the web page is shown in your browser, enabling you to access the requested material.</p><p>View the illustration below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*Zbfem2rVcraoYmdFrc7qGg.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99ecc3eaca5b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>