Skip to main content

Command Palette

Search for a command to run...

Exploring Web Server Configurations for Different Use Cases ๐ŸŒ

Published
โ€ข3 min readโ€ขView as Markdown
Exploring Web Server Configurations for Different Use Cases ๐ŸŒ
P

๐Ÿ‘‹ Hello! I'm passionate about DevOps and have over 1+ years of experience in the field. I'm proficient in a variety of cutting-edge technologies and always motivated to expand my knowledge and skills. Let's connect and grow together!

SKILLS:

๐Ÿ”น Languages & Runtimes: Python, Shell Scripting, HCL, YAML ๐Ÿ”น Cloud Technologies: AWS, Microsoft Azure, GCP ๐Ÿ”น Infrastructure Tools: Docker, Terraform, AWS CloudFormation ๐Ÿ”น Other Tools: Linux, Git and GitHub Actions, Jenkins, Jira, GitLab (beginner), Docker, AWS DevOps ๐Ÿ”น Web Development: HTML, CSS, Bootstrap, Python, SQL

Job & Responsibilities:

๐Ÿš€ Improved development efficiency by implementing CI/CD pipelines, resulting in a 30% reduction in deployment time on the test server. ๐Ÿ”’ Strengthened deployment and testing reliability by utilizing Docker containers and optimizing Dockerfile, reducing development issues on the test server by 20%. โš™๏ธ Automated S3 bucket log creation with Shell scripting, eliminating 100% of manual search and saving 2 hours per week. ๐Ÿ“… Scheduled EC2 instance start/stop using Lambda functions and Event Bridge, leading to a 25% decrease in infrastructure costs. ๐Ÿ”ง Utilized AWS, Linux, Python, Docker, Shell scripting, Terraform, Jenkins Pipelines, and automation to streamline workflows and improve overall system performance.

I'm very detail-oriented and possess strong written and verbal communication skills. As a high performer with a possibility mindset, I strive to solve problems using efficient approaches.

Let's Connect & Grow:

If you find my profile suitable for the role you are searching for, please feel free to reach out to me at sumanprasad9766@gmail.com.

๐Ÿ“Introduction:

In the world of web hosting and applications, the choice of a web server plays a crucial role in determining the performance, security, and accessibility of your online presence. Let's dive into the setup of three popular web serversโ€”nginx, HAProxy, and Apache 2โ€”each tailored to distinct use cases. ๐Ÿš€

Ejecutar Apache Nginx y HAProxy en el mismo servidor ubuntu 20.04 -  Tecnolitas

Nginx - Restricting Access Using nginx.conf ๐Ÿšง

Use Case: Control Access to Sensitive Areas

Steps:

  1. ๐Ÿ“ Open your nginx configuration file at /etc/nginx/nginx.conf.

  2. ๐Ÿ“ Within the server block, add a location block for the restricted area:

     server {
         listen 80;
         server_name yourdomain.com;
    
         location /restricted {
             deny all;
             return 403;
         }
    
         # ... other configuration ...
     }
    
  3. ๐Ÿ’พ Save the configuration file and restart nginx:

     sudo systemctl restart nginx
    
  4. ๐ŸŒ Accessing /restricted will now yield a 403 Forbidden error.

Apache vs Nginx: Melihat Perbedaannya Secara Mendalam

HAProxy - Software Load Balancing & SSL Certificates โš–๏ธ๐Ÿ”

Use Case: Load Balancing and SSL Termination

Steps:

  1. ๐Ÿ“ Install HAProxy using:

     sudo apt-get install haproxy
    
  2. ๐Ÿ“ Edit your HAProxy configuration file at /etc/haproxy/haproxy.cfg.

  3. ๐Ÿ“ Configure the frontend for SSL termination:

     frontend https_frontend
         bind *:443 ssl crt /etc/haproxy/ssl/your_certificate.pem
         mode http
         option httplog
         default_backend backend_servers
    
  4. ๐Ÿ“ Define the backend servers:

     backend backend_servers
         mode http
         balance roundrobin
         server webserver1 192.168.1.10:80
         server webserver2 192.168.1.11:80
         # Add more servers as needed
    
  5. ๐Ÿ’พ Save the configuration and restart HAProxy:

     sudo systemctl restart haproxy
    

Apache 2 - Setting Up a Web Server ๐Ÿ› ๏ธ

Use Case: Basic Web Hosting

Steps:

  1. ๐Ÿ“ Install Apache 2 with:

     sudo apt-get install apache2
    
  2. ๐Ÿ“ Place your website files in /var/www/html.

  3. ๐Ÿ“ Create a virtual host configuration:

     sudo nano /etc/apache2/sites-available/your_site.conf
    
     <VirtualHost *:80>
         ServerName yourdomain.com
         DocumentRoot /var/www/html/your_site
         # Other configuration directives
     </VirtualHost>
    
  4. ๐Ÿ“ Enable the virtual host and necessary modules:

     sudo a2ensite your_site.conf
     sudo a2enmod rewrite
    
  5. ๐Ÿ“ For SSL, use Let's Encrypt certificates with certbot:

     sudo apt-get install certbot python3-certbot-apache
     sudo certbot --apache
    
  6. ๐Ÿ’พ Restart Apache:

     sudo systemctl restart apache2
    

Choose the Right Web Server for Your Needs! ๐Ÿ›ก๏ธ

๐Ÿ“ Conclusion:

Each web server discussed above has its strengths, making them suitable for different scenarios. Nginx excels at access control, HAProxy shines as a load balancer and SSL terminator, and Apache 2 offers a robust foundation for general web hosting. Tailor your choice to your project's unique requirements and enjoy a seamlessly running web application. ๐Ÿš€๐ŸŒ.

๐Ÿ” Checkout GitHub Repository for projects:

๐Ÿ”— https://linktr.ee/sumanprasad007

๐Ÿ” Check out my YouTube channel - Prasad Suman Mohan:

๐Ÿ”— youtube.com/@sumanprasad007

More from this blog

D

DeployToCloud

405 posts

๐Ÿ‘‹ Welcome to my Hashnode blog! I'm a DevOps Engineer with 2+ years of experience. Join ~5k followers and explore 320+ blogs on Python, AWS, Docker, Jenkins, Linux, and more. Let's connect & grow ๐Ÿš€