Skip to content

Commit

Permalink
Initialize proxy template
Browse files Browse the repository at this point in the history
* Allow to proxy to external service
* Could be useful during web migration
  • Loading branch information
camlafit committed Dec 21, 2021
0 parents commit 9b9122d
Show file tree
Hide file tree
Showing 10 changed files with 197 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
debian/*.debhelper.log
debian/*.substvars
debian/alternc-*
debian/files
debian/.debhelper
debian/debhelper-build-stamp
*.gpg
15 changes: 15 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
alternc-proxy (0.0.0+211221102517) UNRELEASED; urgency=medium

* autobuild
* autobuild
* autobuild

-- Camille Lafitte <[email protected]> Tue, 21 Dec 2021 10:25:17 +0100

alternc-proxy (0.0.1) stable; urgency=low

* Provide a proxy template
Redirect domain to other server

-- Camille Lafitte <[email protected]> Tue, 21 Dec 2021 09:52:00 +0200

1 change: 1 addition & 0 deletions debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9
16 changes: 16 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Source: alternc-proxy
Section: admin
Priority: optional
Maintainer: Benjamin Sonntag <[email protected]>
Build-Depends: debhelper (>= 9),
devscripts,
git
Standards-Version: 3.9.8

Package: alternc-proxy
Architecture: all
Depends: apt-utils,
, debconf
, alternc (>= 3.5.0~rc1),
Description: Provide proxy templating
Homepage: https://alternc.com/
29 changes: 29 additions & 0 deletions debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: alternc-acme
Source: https://github.com/AlternC/alternc-acme

Files: *
Copyright: Copyright 2015-2017 AlternC's development Team <[email protected]>
License: GPL-3
This program is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later
version.
.
This program is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more
details.
.
You should have received a copy of the GNU General Public
License along with this package; if not, write to the Free
Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Boston, MA 02110-1301 USA
.
On Debian systems, the full text of the GNU General Public
License version 3 can be found in the file
`/usr/share/common-licenses/GPL-3'.

1 change: 1 addition & 0 deletions debian/install
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/* .
32 changes: 32 additions & 0 deletions debian/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#! /bin/bash
# postinst script
#

set -e

case "$1" in
configure)

if [ -e /usr/share/apache2/apache2-maintscript-helper ]; then
. /usr/share/apache2/apache2-maintscript-helper
apache2_has_module proxy_http || apache2_invoke enmod proxy_http 2>/dev/null || exit $?
fi

echo "Installing mysql table"
mysql --defaults-file=/etc/alternc/my.cnf -e "
INSERT IGNORE INTO domaines_type SET name='proxy', description='Proxy to remote server', target='DOMAIN', entry='%SUB% IN A @@PUBLIC_IP@@', compatibility='txt,defmx,defmx2,mx,mx2', enable='ALL', need_dns=0, has_https_option=0, create_targetdir=0;
UPDATE sub_domaines SET web_action='UPDATE' WHERE type IN ('proxy');
"
;;

abort-upgrade|abort-remove|abort-deconfigure)

;;

*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac

#DEBHELPER#
37 changes: 37 additions & 0 deletions debian/postrm
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#! /bin/bash
# postrm script
#

set -e

case "$1" in
remove|purge)

echo "Remove template configuration"
mysql --defaults-file=/etc/alternc/my.cnf -e "
DELETE FROM domaines_type WHERE name='proxy';
"
# Run also specific purge action
;&

purge)

if [ -e /usr/share/debconf/confmodule ]; then
# Source debconf library.
. /usr/share/debconf/confmodule
# Remove my changes to the db.
db_purge
fi
;;

upgrade|disappear|failed-upgrade|abort-install|abort-upgrade)

;;

*)
echo "postrm called with unknown argument \`$1'" >&2
exit 1
;;
esac

#DEBHELPER#
32 changes: 32 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# This file is public domain software, originally written by Joey Hess.
#
# This version is for a multibinary package. It also allows you to build any
# of the binary packages independantly, via binary-<package> targets.

# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1

#Define version packaging
#Exclude nighly version
VERSION=$(shell git tag -l --points-at HEAD |grep -v 'nightly')
ifeq ($(strip $(VERSION)),)
VERSION=$(shell git tag | sort -V |grep -v nightly|tail -1)
ifeq ($(strip $(VERSION)),)
export VERSION="0.0.0"
endif
VERSION:=$(VERSION)+$(shell date +'%y%m%d%H%M%S')
IS_NIGHTLY=1
endif

clean:
dh clean
rm -f debian/files
(git rev-parse --git-dir > /dev/null 2>&1 && git checkout debian/changelog) || true
ifeq ($(strip $(IS_NIGHTLY)),1)
(git rev-parse --git-dir > /dev/null 2>&1 && dch -m -b -v $(VERSION) autobuild) || true
endif
%:
dh $@

27 changes: 27 additions & 0 deletions src/etc/alternc/templates/apache2/proxy.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<VirtualHost *:80>
ServerName %%fqdn%%

ProxyPreserveHost On
ProxyPass / http://%%%redirect%%%/
ProxyPassReverse / http://%%redirect%%/
</VirtualHost>

<VirtualHost *:443>
ServerName %%fqdn%%

SSLEngine On
SSLCertificateFile %%CRT%%
SSLCertificateKeyFile %%KEY%%
%%CHAINLINE%%

SSLProxyEngine on
SSLProxyVerify none
SSLProxyCheckPeerCN off

SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off

ProxyPreserveHost On
ProxyPass / https://%%redirect%%/
ProxyPassReverse / https://%%redirect%%/
</VirtualHost>

0 comments on commit 9b9122d

Please sign in to comment.