Files
cloud-apache-container/configs/shared-vhost-template.tpl
jknapp e5e055d198
Some checks failed
Cloud Apache Container / Build-and-Push (74) (push) Successful in 2m1s
Cloud Apache Container / Build-and-Push (80) (push) Successful in 2m25s
Cloud Apache Container / Build-and-Push (81) (push) Successful in 2m15s
Cloud Apache Container / Build-and-Push (82) (push) Successful in 1m18s
Cloud Apache Container / Build-and-Push (83) (push) Successful in 2m17s
Cloud Apache Container / Build-and-Push (84) (push) Successful in 2m46s
Cloud Apache Container / Build-and-Push (85) (push) Successful in 1m18s
Cloud Apache Container / Build-FPM-Images (74) (push) Successful in 1m18s
Cloud Apache Container / Build-FPM-Images (81) (push) Has been cancelled
Cloud Apache Container / Build-FPM-Images (82) (push) Has been cancelled
Cloud Apache Container / Build-FPM-Images (83) (push) Has been cancelled
Cloud Apache Container / Build-FPM-Images (84) (push) Has been cancelled
Cloud Apache Container / Build-FPM-Images (85) (push) Has been cancelled
Cloud Apache Container / Build-Shared-httpd (push) Has been cancelled
Cloud Apache Container / Build-FPM-Images (80) (push) Has been cancelled
Fix ProxyFCGISetEnvIf syntax for SCRIPT_FILENAME rewrite
The previous expr= with s|...|...| substitution syntax doesn't exist
in Apache expressions — it silently failed, leaving SCRIPT_FILENAME
pointing to /mnt/users/ which PHP-FPM can't find.

Fixed to use regex match in the conditional with backreferences:
  reqenv('SCRIPT_FILENAME') =~ m#^/mnt/users/([^/]+)/([^/]+)/public_html(.*)#
  -> /home/$1/public_html$3

This is also generic (captures user from the path) so the template
no longer needs per-user placeholder substitution for this directive.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 12:32:52 -07:00

46 lines
1.5 KiB
Smarty

<Directory "/mnt/users/~~user~~/~~domain~~">
AllowOverride None
Require all granted
</Directory>
<Directory "/mnt/users/~~user~~/~~domain~~/public_html">
Options All MultiViews
AllowOverride All
Require all granted
</Directory>
<VirtualHost *:80>
ServerName "~~domain~~"
~~alias_block~~
DocumentRoot "/mnt/users/~~user~~/~~domain~~/public_html"
RewriteEngine on
RewriteCond %{SERVER_NAME} =~~domain~~
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName "~~domain~~"
~~alias_block~~
DocumentRoot "/mnt/users/~~user~~/~~domain~~/public_html"
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
<FilesMatch \.php$>
SetHandler "proxy:fcgi://~~fpm_host~~:~~fpm_port~~"
</FilesMatch>
# Rewrite SCRIPT_FILENAME for PHP-FPM: the shared httpd serves from
# /mnt/users/{user}/{domain}/public_html but the FPM container has
# files at /home/{user}/public_html. Use regex match with backreferences
# to reconstruct the correct path for the FPM container.
ProxyFCGISetEnvIf "reqenv('SCRIPT_FILENAME') =~ m#^/mnt/users/([^/]+)/([^/]+)/public_html(.*)#" SCRIPT_FILENAME "/home/$1/public_html$3"
DirectoryIndex index.php index.html index.htm
ErrorLog "/var/log/httpd/~~domain~~-error.log"
CustomLog "/var/log/httpd/~~domain~~-access.log" combined
</VirtualHost>
</IfModule>