mkdir -p /usr/local/psa/admin/conf/templates/custom/webmail
mkdir -p /usr/local/psa/admin/conf/templates/custom/webmail
cp -p /usr/local/psa/admin/conf/templates/default/webmail/nginxWebmailPartial.php /usr/local/psa/admin/conf/templates/custom/webmail/
if ($host ~* ^<?php echo $alias->asciiName ?>$) {
rewrite ^(.*)$ https://webmail.<?php echo $alias->asciiName ?>$1 permanent;
}
<?php /** @var Template_VariableAccessor $VAR */ ?>
<?php
if (!$VAR->domain->webmail->isActive) {
echo "# Webmail is not enabled on the domain\n";
return;
}
?>
<?php foreach ($VAR->domain->webmail->ipAddresses as $ipAddress): ?>
server {
listen <?php echo $ipAddress->escapedAddress . ':' . $OPT['frontendPort'] . ($OPT['ssl'] ? ' ssl' : '') ?>;
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->server->sni && $VAR->domain->webmail->sslCertificate
? $VAR->domain->webmail->sslCertificate
: $ipAddress->sslCertificate; ?>
<?php if ($sslCertificate->ce): ?>
ssl_certificate <?php echo $sslCertificate->ceFilePath ?>;
ssl_certificate_key <?php echo $sslCertificate->ceFilePath ?>;
<?php if ($sslCertificate->ca): ?>
ssl_client_certificate <?php echo $sslCertificate->caFilePath ?>;
<?php endif ?>
<?php endif ?>
<?php endif ?>
client_max_body_size 128m;
location / {
<?php if ($OPT['ssl']): ?>
proxy_pass https://<?php echo $ipAddress->proxyEscapedAddress . ':' . $OPT['backendPort'] ?>;
<?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;
}
if ($host ~* ^<?php echo $alias->asciiName ?>$) {
rewrite ^(.*)$ https://webmail.<?php echo $alias->asciiName ?>$1 permanent;
}
}
<?php endforeach; ?>
plesk sbin httpdmng --reconfigure-all
cp /usr/local/psa/admin/conf/templates/default/webmail/roundcube.php /usr/local/psa/admin/conf/templates/custom/webmail/
vim /usr/local/psa/admin/conf/templates/custom/webmail/roundcube.php
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
/usr/local/psa/admin/sbin/httpdmng --reconfigure-all
<?php /** @var Template_VariableAccessor $VAR */ ?>
<?php
if (!$VAR->domain->webmail->isActive) {
echo "# Webmail is not enabled on the domain\n";
return;
}
?>
<?php foreach ($VAR->domain->webmail->ipAddresses as $ipAddress): ?>
server {
listen <?php echo $ipAddress->escapedAddress . ':' . $OPT['frontendPort'] . ($OPT['ssl'] ? ' ssl' : '') ?>;
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->server->sni && $VAR->domain->webmail->sslCertificate
? $VAR->domain->webmail->sslCertificate
: $ipAddress->sslCertificate; ?>
<?php if ($sslCertificate->ce): ?>
ssl_certificate <?php echo $sslCertificate->ceFilePath ?>;
ssl_certificate_key <?php echo $sslCertificate->ceFilePath ?>;
<?php if ($sslCertificate->ca): ?>
ssl_client_certificate <?php echo $sslCertificate->caFilePath ?>;
<?php endif ?>
<?php endif ?>
<?php endif ?>
client_max_body_size 128m;
location / {
<?php if ($OPT['ssl']): ?>
proxy_pass https://<?php echo $ipAddress->proxyEscapedAddress . ':' . $OPT['backendPort'] ?>;
<?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;
}
if ($host ~* ^<?php echo $alias->asciiName ?>$) {
rewrite ^(.*)$ https://webmail.<?php echo $alias->asciiName ?>$1 permanent;
}
}
<?php endforeach; ?>
if (!-f $request_filename){
set $rule_1 1$rule_1;
}
if (!-d $request_filename){
set $rule_1 2$rule_1;
}
if ($rule_1 = "21"){
rewrite /. /index.php last;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
root@plesk:/etc# plesk sbin httpdmng --reconfigure-all
Warning: Current locale is unusable. Using 'C' instead.
Hi swaan,
did you create the subdomain "webmail.YOUR-DOMAIN.COM" at your subscriptions? ( I asked this, because you added "Additional nginx directives" ).
In addition, pls. note, that the Plesk KB - article has been updated by now, to cover as well Plesk Onyx resolutions:
Note: Plesk services (for example, Webmail) continue working using Apache and are not affected by switching to nginx-only hosting.
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 11 Oct 2017 16:03:17 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Expires: Wed, 11 Oct 2017 16:03:17 GMT
Cache-Control: private, no-cache, no-store, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
X-DNS-Prefetch-Control: off
X-Frame-Options: sameorigin
Content-Language: en
Set-Cookie: roundcube_sessid=cahe950l734e7m3glcrj1nq5n5; path=/; HttpOnly
Last-Modified: Wed, 11 Oct 2017 16:03:17 GMT