[Linux] Create a self-signed certificate with Docker and apache

Introduction

Note how to create a self-signed certificate with Docker Apache

Environmental information

Docker environment construction

See article below [Linux] Docker environment construction on Redhat

docker-compose.yml settings

version: '3'

services:
  apache:
    build: apache
    container_name: apache
    ports:
      - 80:80
    volumes:
      - ./apache/conf/httpd.conf:/usr/local/apache2/conf/httpd.conf

Dockerfile settings

apache

FROM httpd:latest

RUN apt update \
    && apt install -y \
    git \
    gcc \
    make \
    build-essential \
    wget \
    curl \
    llvm \
    xz-utils \
    tk-dev \
    zlib1g-dev \
    libncurses5-dev \
    libbz2-dev \
    libreadline-dev \
    libsqlite3-dev \
    libssl-dev \
    libxml2-dev \
    libxmlsec1-dev \
    liblzma-dev \
    libpq-dev \
    libffi-dev

WORKDIR /usr/local/apache2

Start apache container

docker-compose up -d apache

Create a self-signed certificate

Enter the apache container and create a self-signed certificate See the article below for details [Apache] Create self-signed certificate

fix docker-compose.yml

-Add the created self-signed certificate to volumes ・ Added "443" to ports

version: '3'

services:
  apache:
    build: apache
    container_name: apache
    ports:
      - 80:80
      - 443:443 <==add to
    volumes:
      - ./apache/conf/httpd.conf:/usr/local/apache2/conf/httpd.conf
      - ./apache/conf/server.crt:/usr/local/apache2/conf/server.crt <==add to
      - ./apache/conf/server.key:/usr/local/apache2/conf/server.key <==add to

Settings for various files

./apache/conf/httpd.conf

・ ・ ・
LoadModule ssl_module modules/mod_ssl.so <==add to
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so <==add to

・ ・ ・
↓↓↓↓↓↓↓↓↓↓ Added ↓↓↓↓↓↓↓↓↓↓
Include conf/extra/httpd-ssl.conf 
<IfModule ssl_module>
  SSLRandomSeed startup builtin
  SSLRandomSeed connect builtin
</IfModule>
↑↑↑↑↑↑↑↑↑↑ Added ↑↑↑↑↑↑↑↑↑↑

Update apache container

docker-compose up -d apache

OK if HTTPS connection is possible https://localhost

Recommended Posts

[Linux] Create a self-signed certificate with Docker and apache
Build a CentOS Linux 8 environment with Docker and start Apache HTTP Server
[Linux] Create a self-signed certificate with Docker and apache
HTTPS with Django and Let's Encrypt
[Linux] Build a jenkins environment with Docker
Create a web service with Docker + Flask
Create a C ++ and Python execution environment with WSL2 + Docker + VSCode
Create a simple Python development environment with VS Code and Docker
[Linux] Build a Docker environment with Amazon Linux 2
Create a native GUI app with Py2app and Tkinter
Create Amazon Linux with AWS EC2 and log in
Create a Layer for AWS Lambda Python with Docker
Create a 3D model viewer with PyQt5 and PyQtGraph
Create a heatmap with pyqtgraph
Create a directory with python
Create a VS Code + Docker development environment on a Linux VM
Create applications, register data, and share with a single email
Let's create a PRML diagram with Python, Numpy and matplotlib.
Build Docker environment (Linux 8) and start Apache HTTP Server container
Create a simple Python development environment with VSCode & Docker Desktop
Create a deploy script with fabric and cuisine and reuse it
Create a Todo app with Django ① Build an environment with Docker
Build a LAMP environment with Vagrant (Linux + Apache + MySQL + PHP)
Steps to create a Job that pulls a Docker image and tests it with Github Actions
Steps to set up Pipenv, create a CRUD app with Flask, and containerize it with Docker
[MariaDB] Install MariaDB on Linux and create a DB and an operating user.
Easy Slackbot with Docker and Errbot
Create a temporary file with django as a zip file and return it
Creating a Flask server with Docker
Build a deb file with Docker
Deploy a Django application with Docker
Create a virtual environment with Python!
Create a Linux environment on Windows 10
Create a private DMP with zero initial cost and zero development with BigQuery
I tried to create Bulls and Cows with a shell program
I want to create a pipfile and reflect it in docker
Create a development environment for Go + MySQL + nginx with Docker (docker-compose)
Create a poisson stepper with numpy.random
Create a file uploader with Django
Create and return a CP932 CSV file for Excel with Chalice
[DynamoDB] [Docker] Build a development environment for DynamoDB and Django with docker-compose
I compared hardware, software, OS, and Linux with a game console
Replace the directory name and the file name in the directory together with a Linux command.
[AWS] Create a Python Lambda environment with CodeStar and do Hello World
Create a socket with an Ethernet interface (eth0, eth1) (Linux, C, Raspberry Pi)
Create a stack with a queue and a queue with a stack (from LetCode / Implement Stack using Queues, Implement Queue using Stacks)
Create a permanent write area on Kali Linux with USB memory boot
Create a Todo app with Django ④ Implement folder and task creation functions
Create a Python3 environment with pyenv on Mac and display a NetworkX graph
Create a decision tree from 0 with Python and understand it (5. Information Entropy)
Create a Python function decorator with Class
Building a Python3 environment with Amazon Linux2
Build a blockchain with Python ① Create a class
Create a dummy image with Python + PIL.
Set up a Samba server with Docker
[Python] Create a virtual environment with Anaconda
Let's create a free group with Python
Create a GUI app with Python's Tkinter
Let's try gRPC with Go and Docker
Get a local DynamoDB environment with Docker
Let's scrape a dynamic site with Docker
Create Python + uWSGI + Nginx environment with Docker