Archive

Posts Tagged ‘Plesk’

Plesk: RewriteRule to redirect from subdomains mail, ftp, ns1, ns2 to main domain

November 11th, 2009 Comments off

By default in Plesk the is such interesting configuration. When you try to access virtual subdomain, for example mail.domain.com or ftp.domain.com, via HTTP, in browser you see the last added in Plesk domain!

To fix it you’ll need to write additional Apache .conf file:

<VirtualHost <ip1>:80 <ip2>:80 <ip3>:80>
 ServerName mail
 ServerAlias mail.*
 ServerAlias ns1.*
 ServerAlias ns2.*
 ServerAlias ftp.*

 RewriteEngine On
 RewriteCond %{HTTP_HOST} ^(?:www\.)?(?:ftp|mail|ns1|ns2)\.(.*)$ [NC]
 RewriteRule ^(.*) http://%1$1 [L,R]

</VirtualHost>

<IfModule mod_ssl.c>
<VirtualHost  <ip1>:443 <ip2>:443 <ip3>:443>
 ServerName mail
 ServerAlias mail.*
 ServerAlias ns1.*
 ServerAlias ns2.*
 ServerAlias ftp.*

 RewriteEngine On
 RewriteCond %{HTTP_HOST} ^(?:www\.)?(?:ftp|mail|ns1|ns2)\.(.*)$ [NC]
 RewriteRule ^(.*) https://%1$1 [L,R]

</VirtualHost>
</IfModule>

Name this file subdomains_redirect.conf and place it to /etc/httpd/conf.d or /etc/apache2/conf.d

Download subdomains_redirect.conf (590 bytes)

Categories: Linux Tags: ,

Plesk backup domains from command line (multibackups)

January 18th, 2009 Comments off

Once I needed to backup all my 200 domains from Plesk, exclude 5-6 domains. There is no opportunity to do it via Plesk web-interface.. (You can only schedule each(!) domain separately).

So, after long time search, I’ve found my own solution.

I’ve wrote simple bash-script:

#!/bin/bash

maxbackups=2 # 3-1=2, numering from zero
file=./counter

counter=`head -n 1 $file`
let counter=counter+1
if [ "$counter" -gt "$maxbackups" ]; then
    let counter=0
fi
`echo $counter > $file`

for domainname in `ls -l /var/www/vhosts/ | grep ^d | awk '{print $9}'`
do
`/usr/local/bin/pleskbackup --domains-name $domainname --output-file=ftp://user:password@server/$domainname-$counter.xml.tar --exclude-domain-file=/root/pleskbackup/excludelist`
done

New feature: you can now store more than one backup! Just create file with name “counter” and contents “0”. Enjoy!

Categories: Linux Tags: , ,