# Apache2-VHost für www.pro-admintool.de (nur CMS-Update-API)
#
# Auf rz1 installieren (Dateien liegen in /var/www/cms-update-api/, NICHT im Bare-Repo):
#   sudo bash /var/www/cms-update-api/install-apache-vhost-rz1.sh
#
# Oder manuell:
#   sudo cp /var/www/cms-update-api/pro-admintool-update-api.apache.conf \
#           /etc/apache2/sites-available/pro-admintool.conf
#   sudo a2ensite pro-admintool
#   sudo a2enmod rewrite headers proxy_fcgi setenvif
#   sudo apache2ctl configtest && sudo systemctl reload apache2
#
# SSL (Let's Encrypt, danach HTTPS für RZ9-CMS):
#   sudo apt install certbot python3-certbot-apache
#   sudo certbot --apache -d www.pro-admintool.de -d pro-admintool.de
#
# Test HTTP (vor SSL):
#   curl -sI 'http://www.pro-admintool.de/cms-update-api/cms-update-api.php?action=status' | head -1
#   → HTTP/1.1 403
#
# Test HTTPS (nach certbot):
#   curl -sI 'https://www.pro-admintool.de/cms-update-api/cms-update-api.php?action=status' | head -1

<VirtualHost *:80>
	ServerName www.pro-admintool.de
	ServerAlias pro-admintool.de
	ServerAdmin webmaster@localhost

	DocumentRoot /var/www/www.pro-admintool.de/html

	# Git-Repo für die API (Fallback, PHP liest auch cms-update-env.sh)
	SetEnv CMS_UPDATE_REPO /var/www/cms-default

	<Directory /var/www/www.pro-admintool.de/html>
		Options FollowSymLinks
		AllowOverride All
		Require all granted
	</Directory>

	# Symlink-Ziel: /var/www/cms-update-api (inkl. .htaccess)
	<Directory /var/www/cms-update-api>
		Options FollowSymLinks
		AllowOverride All
		Require all granted
	</Directory>

	# PHP 8.3 via FPM (Debian/Ubuntu – Socket ggf. anpassen: ls /run/php/)
	<FilesMatch \.php$>
		SetHandler "proxy:unix:/run/php/php8.3-fpm.sock|fcgi://localhost"
	</FilesMatch>

	# Nur Update-API – alles andere 404
	RewriteEngine On
	RewriteCond %{REQUEST_URI} !^/cms-update-api/
	RewriteRule ^ - [R=404,L]

	ErrorLog ${APACHE_LOG_DIR}/pro-admintool-error.log
	CustomLog ${APACHE_LOG_DIR}/pro-admintool-access.log combined
</VirtualHost>

# Nach certbot --apache erscheint hier zusätzlich ein <VirtualHost *:443>-Block
# (oder eine Datei pro-admintool-le-ssl.conf). Dann HTTPS-Test wie oben.
