inital
This commit is contained in:
commit
e5160ddeaf
3 changed files with 79 additions and 0 deletions
19
rewrite_apache_conf.py
Executable file
19
rewrite_apache_conf.py
Executable file
|
@ -0,0 +1,19 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
INCLUDE_MATCH = re.compile(r"\s*include\s+(.*)\s*")
|
||||||
|
SERVERNAME_MATCH = re.compile(r"\s*ServerName\s+(.*)\s*")
|
||||||
|
SERVERALIAS_MATCH = re.compile(r"\s*ServerAlias\s+(.*)\s*")
|
||||||
|
|
||||||
|
with Path(sys.argv[1]).open("r") as original:
|
||||||
|
lines = original.readlines()
|
||||||
|
includes = set(x[1] for x in map(INCLUDE_MATCH.match, lines) if x)
|
||||||
|
server_name = set(x[1] for x in map(SERVERNAME_MATCH.match, lines) if x)
|
||||||
|
server_alias = set(x[1] for x in map(SERVERALIAS_MATCH.match, lines) if x)
|
||||||
|
print(f"includes: {includes}")
|
||||||
|
print(f"server_name: {server_name}")
|
||||||
|
print(f"server_alias: {server_alias}")
|
35
testdata/site.conf
vendored
Normal file
35
testdata/site.conf
vendored
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
<VirtualHost 127.0.0.1:80 [::2]:80>
|
||||||
|
ServerName site.de
|
||||||
|
ServerAlias www.site.de
|
||||||
|
ServerAdmin webmaster@site.de
|
||||||
|
|
||||||
|
include /etc/apache2/vhosts.d/site.include
|
||||||
|
|
||||||
|
# This checks to make sure the connection is not already HTTPS
|
||||||
|
# RewriteEngine on
|
||||||
|
RewriteCond %{HTTPS} off
|
||||||
|
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
|
||||||
|
|
||||||
|
</VirtualHost>
|
||||||
|
|
||||||
|
<IfModule mod_ssl.c>
|
||||||
|
<VirtualHost 127.0.0.1:443 [::2]:443>
|
||||||
|
|
||||||
|
SSLEngine on
|
||||||
|
SSLCertificateFile /etc/dehydrated/certs/site.de/fullchain.pem
|
||||||
|
SSLCertificateKeyFile /etc/dehydrated/certs/site.de/privkey.pem
|
||||||
|
SSLUseStapling On
|
||||||
|
|
||||||
|
ServerName site.de
|
||||||
|
ServerAlias www.site.de
|
||||||
|
ServerAdmin webmaster@site.de
|
||||||
|
|
||||||
|
Header always set Strict-Transport-Security "max-age=31536000;"
|
||||||
|
|
||||||
|
include /etc/apache2/vhosts.d/site.de.include
|
||||||
|
|
||||||
|
|
||||||
|
</VirtualHost>
|
||||||
|
|
||||||
|
</IfModule>
|
||||||
|
|
25
testdata/test.conf
vendored
Normal file
25
testdata/test.conf
vendored
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<VirtualHost 127.0.0.1:80 [::2]:80>
|
||||||
|
include /etc/apache2/vhosts.d/site.de.include
|
||||||
|
RewriteEngine On
|
||||||
|
# Redirect / https://%{HTTP_HOST}/
|
||||||
|
RewriteRule ^.*$ https://site.de%{REQUEST_URI} [L,R=permanent]
|
||||||
|
</VirtualHost>
|
||||||
|
|
||||||
|
<IfModule mod_ssl.c>
|
||||||
|
<VirtualHost 136.243.66.40:443 [2a01:4f8:212:2027::2]:443>
|
||||||
|
<VirtualHost 127.0.0.1:443 [::2]:443>
|
||||||
|
SSLEngine on
|
||||||
|
|
||||||
|
SSLCertificateFile /etc/dehydrated/certs/site.de/fullchain.pem
|
||||||
|
SSLCertificateKeyFile /etc/dehydrated/certs/site.de/privkey.pem
|
||||||
|
|
||||||
|
SSLUseStapling Off
|
||||||
|
Header always set Strict-Transport-Security "max-age=31536000;"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
include /etc/apache2/vhosts.d/site.de.include
|
||||||
|
</VirtualHost>
|
||||||
|
|
||||||
|
</IfModule>
|
||||||
|
|
Loading…
Add table
Reference in a new issue