Skip to content

Instantly share code, notes, and snippets.

@zalexki
Last active October 23, 2020 10:06
Show Gist options
  • Select an option

  • Save zalexki/5cdfe4bf67db65f891028aea7467931b to your computer and use it in GitHub Desktop.

Select an option

Save zalexki/5cdfe4bf67db65f891028aea7467931b to your computer and use it in GitHub Desktop.

Revisions

  1. zalexki revised this gist Dec 28, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion docker-https.md
    Original file line number Diff line number Diff line change
    @@ -41,7 +41,7 @@ DNS.2 = fr.sodebo.mydocker
    DNS.3 = en.sodebo.mydocker
    ```

    This will generate a key.pem and server.cert.prem.
    This will generate a key.pem and cert.prem.

    Copy them in proper folder during container build (to add in Dockerfile):
    ```
  2. zalexki revised this gist Dec 26, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion docker-https.md
    Original file line number Diff line number Diff line change
    @@ -43,7 +43,7 @@ DNS.3 = en.sodebo.mydocker

    This will generate a key.pem and server.cert.prem.

    Copy them in proper folder during container build:
    Copy them in proper folder during container build (to add in Dockerfile):
    ```
    COPY ssl/cert.pem /etc/ssl/certs/cert.pem
    COPY ssl/cert.key /etc/ssl/certs/cert.key
  3. zalexki revised this gist Dec 26, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion docker-https.md
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@ Listen 443 https
    </VirtualHost>
    ```

    Create files with openssl and following config file named red.cnf :
    Create files with openssl and following config file named req.cnf :
    `openssl req -x509 -nodes -days 99999 -newkey rsa:2048 -keyout cert.key -out cert.pem -config req.cnf -sha256`

    ```
  4. zalexki renamed this gist Dec 18, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. zalexki revised this gist Dec 18, 2017. 1 changed file with 8 additions and 2 deletions.
    10 changes: 8 additions & 2 deletions docker-https.txt
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,8 @@
    Open port 443 on container.
    Open port 443 on container, with a docker-compose file just add :
    ```
    ports:
    - 443:443
    ```

    Add virtualhost config :
    ```
    @@ -44,4 +48,6 @@ Copy them in proper folder during container build:
    COPY ssl/cert.pem /etc/ssl/certs/cert.pem
    COPY ssl/cert.key /etc/ssl/certs/cert.key
    RUN echo '' > /etc/apache2/ports.conf
    ```
    ```

    We delete default ports apache2 configuration, be sure to add `Listen 80` in virtualhost config if you still use non https version.
  6. zalexki revised this gist Dec 18, 2017. No changes.
  7. zalexki revised this gist Dec 18, 2017. No changes.
  8. zalexki created this gist Dec 18, 2017.
    47 changes: 47 additions & 0 deletions docker-https.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    Open port 443 on container.

    Add virtualhost config :
    ```
    Listen 443 https
    <VirtualHost *:443>
    # Enable/Disable SSL for this virtual host.
    SSLEngine on

    SSLCertificateFile /etc/ssl/certs/cert.pem
    SSLCertificateKeyFile /etc/ssl/certs/cert.key
    </VirtualHost>
    ```

    Create files with openssl and following config file named red.cnf :
    `openssl req -x509 -nodes -days 99999 -newkey rsa:2048 -keyout cert.key -out cert.pem -config req.cnf -sha256`

    ```
    [req]
    distinguished_name = req_distinguished_name
    x509_extensions = v3_req
    prompt = no
    [req_distinguished_name]
    C = FR
    ST = IDF
    L = Clichy
    O = SensioGrey
    OU = PoleTech
    CN = sodebo.mydocker
    [v3_req]
    keyUsage = critical, digitalSignature, keyAgreement
    extendedKeyUsage = serverAuth
    subjectAltName = @alt_names
    [alt_names]
    DNS.1 = www.sodebo.mydocker
    DNS.2 = fr.sodebo.mydocker
    DNS.3 = en.sodebo.mydocker
    ```

    This will generate a key.pem and server.cert.prem.

    Copy them in proper folder during container build:
    ```
    COPY ssl/cert.pem /etc/ssl/certs/cert.pem
    COPY ssl/cert.key /etc/ssl/certs/cert.key
    RUN echo '' > /etc/apache2/ports.conf
    ```