From 4f8950e4d98f28f4b5539598ac8814394d111af9 Mon Sep 17 00:00:00 2001 From: gbaconni Date: Tue, 9 Nov 2021 10:58:55 +0100 Subject: [PATCH] 2021-11-09 10:58:55 --- README.md | 9 +++++++++ bonus.sh | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c552854..2cbec6b 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,14 @@ bash -x bonus.sh -u - Click on the white background - Type `thisisunsafe` +``` +# HTTP (4243 instead of 80) -- redirect to HTTPS +curl -v http://localhost:4243 + +# HTTPS (4244 instead of 443) +curl -sk https://localhost:4244 | less +``` + Debian Preseed: - [Preseed](https://wiki.debian.org/DebianInstaller/Preseed) - [Automating the installation using preseeding](https://www.debian.org/releases/stable/amd64/apb.en.html) @@ -45,6 +53,7 @@ Wordpress: Lighttpd: - [Install Lighttpd with PHP and MariaDB](https://www.howtoforge.com/how-to-install-lighttpd-with-php-and-mariadb-on-debian-10/) - [How to install lighttpd on Debian](https://www.osradar.com/install-lighttpd-debian-10/) +- [lighttpd redirect from custom HTTP port to HTTPS](https://stackoverflow.com/questions/62109311/lighttpd-redirect-from-custom-http-port-81-to-https-port-443) ``` curl -sLo preseed.cfg https://www.debian.org/releases/stable/example-preseed.txt diff --git a/bonus.sh b/bonus.sh index 31b1344..1299ddd 100755 --- a/bonus.sh +++ b/bonus.sh @@ -6,7 +6,7 @@ # By: gbaconni@student.42lausanne.ch +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2021/11/07 14:23:18 by gbaconni #+# #+# # -# Updated: 2021/11/09 09:58:20 by gbaconni ### ########.fr # +# Updated: 2021/11/09 10:58:53 by gbaconni ### ########.fr # # # # **************************************************************************** # @@ -46,6 +46,8 @@ ft_lighttpd () then apt-get install -qq -y lighttpd sed -i -r 's/80/4243/g' /etc/lighttpd/lighttpd.conf + grep -q 'url.redirect' /etc/lighttpd/lighttpd.conf \ + || echo -e '\n$HTTP["scheme"] == "http" {\n\t$HTTP["host"] =~ "([^:]*)(:[0-9]+|)$" {\n\t\turl.redirect = (".*" => "https://%1:4244${url.path}${qsa}")\n\t}\n\turl.redirect-code = 302\n}\n' >> /etc/lighttpd/lighttpd.conf sed -i -r 's/443/4244/g' /etc/lighttpd/conf-available/10-ssl.conf sed -i -r 's|"bin-path"([^=]*=>).*|"host"\1 "127.0.0.1",|g' /etc/lighttpd/conf-available/15-fastcgi-php.conf sed -i -r 's|"socket"([^=]*=>).*|"port"\1 "9000",|g' /etc/lighttpd/conf-available/15-fastcgi-php.conf