Skip to content

tshenolo/docker-Secure-Apache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Secure Apache with SSL in Docker

Docker Apache PHP

This repository provides a guide for setting up an Apache server with PHP support inside a Docker container, secured with an SSL certificate for local development purposes.

Table of Contents

Prerequisites

  • Docker installed on your machine.
  • Basic knowledge of Docker, Apache, and SSL certificates.
  • OpenSSL for generating a self-signed certificate.

Usage

To use this setup, follow these steps:

1. Clone this repository:

git clone https://github.com/tshenolo/docker-Secure-Apache.git
cd docker-Secure-Apache

2. Generate the SSL certificate

Before setting up your Docker container, you need to generate a self-signed SSL certificate for localhost. Open a terminal and run the following command:

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout localhost.key -out localhost.crt -subj "/C=US/ST=YourState/L=YourCity/O=YourOrganization/CN=localhost"

This command generates a new SSL certificate (localhost.crt) and a private key (localhost.key), valid for 365 days.

3. Build the Docker container:

docker build -t apache-php-ssl .

4. Run the container:

docker run -d -p 443:443 apache-php-ssl

Accessing Your Secure Apache Server

Open a web browser and navigate to https://localhost. You should see your PHP application running securely under HTTPS. Since the certificate is self-signed, your browser may warn you about the site's security certificate. You can proceed by allowing an exception for this certificate.

Conclusion

You've successfully set up an Apache server with SSL inside a Docker container, making your local development environment secure and more aligned with production settings. This setup ensures that your development practices include necessary security measures right from the start.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Thank you for the Support

  • ⭐ Give this repo a ⭐ star ⭐ at the top of the page
  • 🐦 Follow me on X
  • 📺 Subscribe to my Youtube channel

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published