yurderi/provisioner

用于在 YAML 文件中配置 Apache 主机(支持 SSL)的配置器

dev-master 2019-01-14 16:41 UTC

This package is not auto-updated.

Last update: 2024-09-18 20:09:38 UTC


README

然而,此项目用于根据 YAML 配置自动创建 apache2 vhost。

安装

# Clone the project
git clone https://github.com/yurderi/provisioner.git

# Symlink executable
ln -s /path/to/provisioner/bin/console /usr/bin/yp

要求

  • apache2
  • certbot

用法

yp run apache <filename>

示例

default:
  # Whether the vhost is the default vhost
  default: false
  # The path where the html files are located
  root: ""
  # Whether the host is enabled or not
  active: true
  # Enable ssl (using certbot --apache)
  ssl: true
  # Rules for the directory directive
  rules:
    - AllowOverride All
  # Additional hosts the website should be available through
  alias: []

hosts:
  www.yurderi.de:
    default: true
    root: /var/www/www.yurderi.de

结果

<VirtualHost *:80>
    DocumentRoot /var/www/www.yurderi.de
    ServerName www.yurderi.de
    ServerAlias *

    <Directory /var/www/www.yurderi.de>
        AllowOverride All
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    RewriteEngine on
    RewriteRule ^ https://www.yurderi.de%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

<IfModule mod_ssl.c>
    <VirtualHost *:443>
        DocumentRoot /var/www/www.yurderi.de
        ServerName www.yurderi.de

        <Directory /var/www/www.yurderi.de>
            AllowOverride All
        </Directory>
        
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        SSLCertificateFile /etc/letsencrypt/live/www.yurderi.de/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/www.yurderi.de/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf
    </VirtualHost>
</IfModule>