Files
server/opt/psa/admin/conf/templates/default/webmail/nginxWebmailPartial.php
cutemeli 0bfc6c8425 Initial
2025-12-22 10:32:59 +00:00

61 lines
2.2 KiB
PHP

<?php /** @var Template_VariableAccessor $VAR */ ?>
<?php /** @var array $OPT */ ?>
<?php
if (!$VAR->domain->webmail->isActive && !$VAR->domain->webmail->suspended) {
echo "# Webmail is not enabled on the domain\n";
return;
}
if ($OPT['ssl'] && !$VAR->domain->webmail->sslCertificate) {
return;
}
?>
<?php foreach ($VAR->domain->webmail->ipAddresses as $ipAddress): ?>
server {
<?php if ($OPT['ssl'] && $OPT['http3']) : ?>
listen <?php echo $ipAddress->escapedAddress . ':' . $OPT['frontendPort'] ?> quic;
add_header Alt-Svc <?php echo '\'h3=":' . $OPT['frontendPort'] . '"; ma=86400\'' ?>;
<?php endif; ?>
listen <?php echo $ipAddress->escapedAddress . ':' . $OPT['frontendPort'] . ($OPT['ssl'] ? ' ssl' : '') ?>;
<?php if ($OPT['ssl'] && $OPT['http2']) : ?>
http2 on;
<?php endif; ?>
server_name "webmail.<?php echo $VAR->domain->asciiName ?>";
<?php foreach ($VAR->domain->mailAliases as $alias): ?>
server_name "webmail.<?php echo $alias->asciiName ?>";
<?php endforeach; ?>
<?php if ($OPT['ssl']): ?>
<?php $sslCertificate = $VAR->domain->webmail->sslCertificate; ?>
<?php if ($sslCertificate->ceFilePath): ?>
ssl_certificate <?php echo $sslCertificate->ceFilePath ?>;
ssl_certificate_key <?php echo $sslCertificate->ceFilePath ?>;
<?php endif ?>
<?php endif ?>
client_max_body_size 128m;
<?php if (!in_array($VAR->domain->webmail->type, ['atmail', 'horde', 'roundcube'])) {
echo "# Using custom webmail type: '{$VAR->domain->webmail->type}'";
} ?>
<?=$VAR->domain->webmail->nginxExtensionsConfigs?>
location / {
<?php if ($OPT['ssl']): ?>
proxy_pass https://<?php echo $ipAddress->proxyEscapedAddress . ':' . $OPT['backendPort'] ?>;
proxy_hide_header upgrade;
proxy_ssl_server_name on;
proxy_ssl_name $host;
proxy_ssl_session_reuse off;
<?php else: ?>
proxy_pass http://<?php echo $ipAddress->proxyEscapedAddress . ':' . $OPT['backendPort'] ?>;
<?php endif ?>
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
<?php endforeach; ?>