Skip to content

Commit

Permalink
✨ [GEST-2855] Configurando SSL no apache
Browse files Browse the repository at this point in the history
- Configurando pastas e mod_rewrite de forma correta.
  • Loading branch information
ricardoapaes committed Feb 17, 2025
1 parent dedfecf commit 1506e60
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 24 deletions.
26 changes: 25 additions & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
run: |
CONTENT=$(curl -s "http://127.0.0.1/");
CONTENT_PHP=$(curl -s "http://127.0.0.1/script.php");
CONTENT_REWRITE=$(curl -s "https://127.0.0.1/rewrite/apache.php");
CONTENT_REWRITE=$(curl -s "http://127.0.0.1/rewrite/apache.php");
echo "CHAMADA HTTP NORMAL: ${CONTENT}";
echo "CHAMADA HTTP PHP: ${CONTENT_PHP}";
echo "CHAMADA HTTP REWRITE: ${CONTENT_REWRITE}";
Expand All @@ -57,6 +57,30 @@ jobs:
exit 1;
fi
- name: Run tests in https
run: |
CONTENT=$(curl -s "https://127.0.0.1/");
CONTENT_PHP=$(curl -s "https://127.0.0.1/script.php");
CONTENT_REWRITE=$(curl -s "https://127.0.0.1/rewrite/apache.php");
echo "CHAMADA HTTP NORMAL: ${CONTENT}";
echo "CHAMADA HTTP PHP: ${CONTENT_PHP}";
echo "CHAMADA HTTP REWRITE: ${CONTENT_REWRITE}";
if [ "${CONTENT}" != "html" ]; then
echo "Chamada HTTP NORMAL retornou errado: ${CONTENT}"
exit 1;
fi

if [ "${CONTENT_PHP}" != "php" ]; then
echo "Chamada HTTP TRYFILES retornou errado: ${CONTENT_PHP}"
exit 1;
fi

if [ "${CONTENT_REWRITE}" != "/rewrite/apache.php" ]; then
echo "Chamada HTTP REWRITE retornou errado: ${CONTENT_REWRITE}"
exit 1;
fi

push:
needs: test

Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ ENV TIMEOUT_PHP=60s

COPY httpd-vhosts.conf /usr/local/apache2/conf/extra/httpd-vhosts.conf
COPY httpd-ssl.conf /usr/local/apache2/conf/extra/httpd-ssl.conf
COPY httpd-php.conf /usr/local/apache2/conf/extra/httpd-php.conf

COPY --from=ssl /ssl/server.crt /usr/local/apache2/conf/server.crt
COPY --from=ssl /ssl/server.key /usr/local/apache2/conf/server.key
RUN ls -la /usr/local/apache2/conf/
Expand Down
3 changes: 3 additions & 0 deletions httpd-php.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<FilesMatch \.php$>
SetHandler "proxy:fcgi://{{ default .Env.HOST_PHP "php" }}:{{ .Env.PORTA_PHP }}"
</FilesMatch>
9 changes: 0 additions & 9 deletions httpd-ssl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ SSLSessionCacheTimeout 300
<VirtualHost _default_:443>

# General setup for the virtual host
DocumentRoot "/var/www/public/"
ServerName localhost
ServerAlias *
ServerAdmin server@likesistemas.com.br
Expand Down Expand Up @@ -253,14 +252,6 @@ SSLCertificateKeyFile "/usr/local/apache2/conf/server.key"
<Directory "/usr/local/apache2/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
<FilesMatch \.php$>
SetHandler "proxy:fcgi://{{ default .Env.HOST_PHP "php" }}:{{ .Env.PORTA_PHP }}"
</FilesMatch>
<Directory /var/www/public/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

# SSL Protocol Adjustments:
# The safe and default but still SSL/TLS standard compliant shutdown
Expand Down
14 changes: 2 additions & 12 deletions httpd-vhosts.conf
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
<VirtualHost *:80>
<FilesMatch \.php$>
SetHandler "proxy:fcgi://{{ default .Env.HOST_PHP "php" }}:{{ .Env.PORTA_PHP }}"
</FilesMatch>

DocumentRoot /var/www/public/

<Directory /var/www/public/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

ServerName localhost
ServerAlias *
ErrorLog /dev/stderr
TransferLog /dev/stdout
</VirtualHost>
18 changes: 16 additions & 2 deletions sh/start
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,22 @@ step() {
}

step "Configurando apache...";
dockerize \
-template conf/extra/httpd-vhosts.conf:conf/extra/httpd-vhosts.conf
dockerize -template conf/extra/httpd-php.conf:conf/extra/httpd-php.conf

sed -i -e 's/^#\(Include .*httpd-vhosts.conf\)/\1/' conf/httpd.conf;
sed -i -e 's/^#\(LoadModule .*mod_rewrite.so\)/\1/' conf/httpd.conf;
sed -i -e 's/^#\(LoadModule .*mod_proxy.so\)/\1/' conf/httpd.conf;
sed -i -e 's/^#\(LoadModule .*mod_proxy_fcgi.so\)/\1/' conf/httpd.conf;

sed -i 's|DirectoryIndex index.html|DirectoryIndex index.php index.html|' conf/httpd.conf
sed -i 's/^User daemon/User www-data/' conf/httpd.conf
sed -i 's/^Group daemon/Group www-data/' conf/httpd.conf

sed -i 's|DocumentRoot "/usr/local/apache2/htdocs"|DocumentRoot "/var/www/public/"|' conf/httpd.conf;
sed -i 's|<Directory "/usr/local/apache2/htdocs">|<Directory "/var/www/public/">|' conf/httpd.conf;
sed -i '/<Directory "\/var\/www\/public\/">/,/<\/Directory>/ s/AllowOverride None/AllowOverride All/' conf/httpd.conf;

echo "Include conf/extra/httpd-php.conf" >> conf/httpd.conf;

if [ "${SSL}" == "true" ]; then
step "Configurando SSL...";
Expand Down

0 comments on commit 1506e60

Please sign in to comment.