From 5681a1da634211ecee84157911d94c9c04c29ac1 Mon Sep 17 00:00:00 2001 From: root Apostolos Date: Sat, 2 Nov 2019 22:20:07 +0200 Subject: [PATCH] proxy --- default-ssl.conf | 28 +++++++++ docker-apache-proxy-ssl/Dockerfile | 59 +++++++++++++++++++ docker-apache-proxy-ssl/Dockerfile.sh | 1 + docker-apache-proxy-ssl/apache-proxy-start.sh | 13 ++++ git-proxy.yaml | 30 ++++++++++ git-proxy.yaml.sh | 2 + git.yaml | 4 +- git.yaml.sh | 1 + 8 files changed, 136 insertions(+), 2 deletions(-) create mode 100755 default-ssl.conf create mode 100644 docker-apache-proxy-ssl/Dockerfile create mode 100755 docker-apache-proxy-ssl/Dockerfile.sh create mode 100644 docker-apache-proxy-ssl/apache-proxy-start.sh create mode 100644 git-proxy.yaml create mode 100755 git-proxy.yaml.sh diff --git a/default-ssl.conf b/default-ssl.conf new file mode 100755 index 0000000..4eca46a --- /dev/null +++ b/default-ssl.conf @@ -0,0 +1,28 @@ + + ServerName git.swarmlab.io + SSLEngine On + + SSLCertificateFile /opt/ssl/yourcertificate.crt + SSLCertificateKeyFile /opt/ssl/yourcertificate.key + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + SSLProxyEngine on + + + ProxyPass / http://localhost:3000/ nocanon + ProxyPassReverse / http://localhost:3000/ + + + ProxyPreserveHost On + ProxyRequests off + AllowEncodedSlashes NoDecode + ProxyPass / https://localhost:3000/ nocanon + ProxyPassReverse / https://localhost:3000/ + Options Indexes FollowSymLinks MultiViews + #AddHandler markdown .md + AllowOverride All + Require all granted + + + diff --git a/docker-apache-proxy-ssl/Dockerfile b/docker-apache-proxy-ssl/Dockerfile new file mode 100644 index 0000000..7d75dc8 --- /dev/null +++ b/docker-apache-proxy-ssl/Dockerfile @@ -0,0 +1,59 @@ +#Choose Debian +FROM debian:jessie + +MAINTAINER DiouxX "github@diouxx.be" + +RUN echo "deb http://ftp.de.debian.org/debian stretch main" >> /etc/apt/sources.list + +#Don't ask questions during install +ENV DEBIAN_FRONTEND noninteractive + +#Install apache2 and enable proxy mode +RUN apt update \ +&& apt -y install \ + apache2 \ +&& rm -rf /var/lib/apt/lists/* + +#libapache2-mod-auth-cas \ + #php7.0-mysql \ + #php7.0-opcache \ + #php7.0-common \ + #curl \ + #php7.0-mbstring \ + #php7.0-mcrypt \ + #php7.0-cli \ + #php7.0-intl \ + #php7.0-json \ + #php7.0-xsl \ + #php7.0-curl \ + #php7.0-memcached \ + #php7.0-readline \ + #php7.0-recode \ + #php7.0-fpm \ + #php7.0 \ + #libapache2-mod-php7.0 libapache2-mod-php \ + +RUN a2enmod proxy \ +&& a2enmod proxy_http \ +&& a2enmod ssl \ +&& a2enmod headers \ +&& a2enmod rewrite \ +&& a2enmod proxy_wstunnel \ +&& service apache2 stop +#&& a2enmod auth_cas \ +#&& a2enmod php7.0 \ + +#Ports +EXPOSE 80 443 8080 + +#Volumes +VOLUME /opt/proxy-conf +VOLUME /opt/ssl +VOLUME /opt/logs +VOLUME /opt/www +VOLUME /opt/private + +#Launch Apache2 on FOREGROUND +COPY apache-proxy-start.sh /opt/ +RUN chmod +x /opt/apache-proxy-start.sh +ENTRYPOINT ["/opt/apache-proxy-start.sh"] diff --git a/docker-apache-proxy-ssl/Dockerfile.sh b/docker-apache-proxy-ssl/Dockerfile.sh new file mode 100755 index 0000000..e280313 --- /dev/null +++ b/docker-apache-proxy-ssl/Dockerfile.sh @@ -0,0 +1 @@ +docker build -t registry.vlabs.uniwa.gr:5080/vlab-apache2-proxy-ssl -t registry.vlabs.uniwa.gr:5043/vlab-apache2-proxy-ssl . diff --git a/docker-apache-proxy-ssl/apache-proxy-start.sh b/docker-apache-proxy-ssl/apache-proxy-start.sh new file mode 100644 index 0000000..7532b4a --- /dev/null +++ b/docker-apache-proxy-ssl/apache-proxy-start.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +#Copy virtualhost on apache directory +cp /opt/proxy-conf/*.conf /etc/apache2/sites-available/ + +#List site and enable +ls /etc/apache2/sites-available/ -1A | a2ensite *.conf + +# Apache gets grumpy about PID files pre-existing +rm -f /var/run/apache2/apache2.pid + +#Launch Apache on Foreground +/usr/sbin/apache2ctl -D FOREGROUND diff --git a/git-proxy.yaml b/git-proxy.yaml new file mode 100644 index 0000000..0368923 --- /dev/null +++ b/git-proxy.yaml @@ -0,0 +1,30 @@ +version: "3.3" +services: + + server_proxy: + #image: registry.vlabs.uniwa.gr:5043/swarmlab-apache2-markdown + image: registry.vlabs.uniwa.gr:5080/vlab-apache2-proxy-ssl:latest + networks: + - git-net + deploy: + replicas: 1 + placement: + constraints: + - node.id == ${REGISTERid} + ports: + - 3000:443 + - 3043:8080 + + + volumes: + - "/var/lib/swarmlab.io/gitproxy/ssl:/opt/ssl" + - "/var/lib/swarmlab.io/gitproxy/conf:/opt/proxy-conf" + - "/var/lib/swarmlab.io/gitproxy/apache2/apache2.conf:/etc/apache2/apache2.conf" + - "/var/lib/swarmlab.io/gitproxy/apache2/ports.conf:/etc/apache2/ports.conf" + - "/var/lib/swarmlab.io/gitproxy/www:/opt/www" + - "/var/lib/swarmlab.io/gitproxy/private:/opt/private" + + +networks: + git-net: + diff --git a/git-proxy.yaml.sh b/git-proxy.yaml.sh new file mode 100755 index 0000000..883fa51 --- /dev/null +++ b/git-proxy.yaml.sh @@ -0,0 +1,2 @@ +docker service rm git_server_proxy +env REGISTERid=c50xzv12mz3cux1mcdz4ypznc docker stack deploy -c git-proxy.yaml git diff --git a/git.yaml b/git.yaml index b285967..99cbba8 100644 --- a/git.yaml +++ b/git.yaml @@ -6,7 +6,7 @@ networks: services: server: - image: gitea/gitea:1.9 + image: gitea/gitea:1.9.4 environment: - USER_UID=1002 - USER_GID=1002 @@ -21,7 +21,7 @@ services: volumes: - /var/lib/gitea:/data ports: - - "3000:3000" + - "3001:3000" - "3080:3080" - "127.0.0.1:2222:22" depends_on: diff --git a/git.yaml.sh b/git.yaml.sh index 3a41e4a..2330f62 100755 --- a/git.yaml.sh +++ b/git.yaml.sh @@ -1 +1,2 @@ +docker service rm git_db git_server env REGISTERid=c50xzv12mz3cux1mcdz4ypznc docker stack deploy -c git.yaml git