Plesk 10 nginx reverse proxy configuration in front of Apache

Plesk 10 nginx reverse proxy configuration

On older Plesk version (

websrvmng –set-http-port –port=8080

Starting with Plesk 10 this is not so easy since you have to edit a php file called /usr/local/psa/admin/conf/templates/default/domain/domainVirtualHost.php. In my case instead of :

domain->physicalHosting->ipAddress->address ?>:server->webserver->httpsPort : $VAR->server->webserver->httpPort ?>>
ServerName "domain->asciiName ?>:server->webserver->httpsPort : $VAR->server->webserver->httpPort ?>"

I’ve set :

 

<VirtualHost <?php echo $OPT[‘ipAddress’]->escapedAddress ?>:<?php echo $OPT[‘ssl’] ? 8043 : 8080 ?>>
ServerName “<?php echo $VAR->domain->asciiName ?>:<?php echo $OPT[‘ssl’] ? 8043 : 8080 ?>”


Where 8043 will be the new https port and 8080 will be the http port.

After this change I had to run :

/usr/local/psa/admin/bin/httpdmng –reconfigure-all

Note that this is only for Plesk 10.x. On 9.x we used to have

/usr/local/psa/admin/sbin/websrvmng –reconfigure-all

After this make sure that the Apache server has set in its configuration files (/etc/httpd/conf/httpd.conf) Listen 8080 instead of Listen 80. Same thing for the /etc/httpd/conf.d/ssl.conf file, Listen 8043 instead of Listen 443.

Then you need to install nginx (yum install nginx) and download this zip file that these guys provided http://www.grafxsoftware.com/download/nginx/nginx_setup.zip. Furthermore you can check their http://www.grafxsoftware.com/faq.php/HOW-TO-configure-PLESK-with-NGinx-proxy-reverse/1/1/.

Once downloaded run:

sh generate_nginx_conf.sh

Verify with “nginx -t” that there isn’t any error and finally restart the involved services :

service httpd restart
service nginx restart

Make sure that 8043 and 8080 accept connections. (Note that its not necessary to change the https port).

Using mod_proxy in Plesk to redirect to a different site

Scenario:

Site1 : www.site.com
Site2 : shop.site2.com

The idea is to make a proxy redirect so if I access www.site.com/shop to be redirected to shop.site2.com and keep the URL in the browser.
This can be done either by using mod_rewrite (if both sites are on the same server) or by using mod_proxy. In my case I had to do this on a Plesk server.

I’ve created in /var/www/vhosts/site.com/conf a file called vhost.conf that contains:

ProxyRequests off
Order deny,allow
Allow from all

ProxyPass /shop http://shop.site2.com
ProxyPassReverse /shop http://shop.site2.com
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1


Order allow,deny
Allow from all

Then I ran:

/usr/local/psa/admin/bin/websrvmng -a -v

Verify httpd.include to see if there is any Include directive.

Now if you go to www.site.com/shop/ you should be redirected to shop.site2.com. Notice the trailing slash after (../shop/). That needs to be there otherwise it won’t load the images properly.

This can be fixed by adding in vhost.conf a Rewrite rule like:
RewriteEngine on
RewriteRule ^/shop$ /shop/ [R]

Bulk adding domains in Plesk

I had one client that wanted to add 400 domains on 4 Windows servers, each server had like 4-5 public ips, so I had to use 4/5 ip for 100 domains.

On Windows this worked fine for me:

FOR /L %i IN (0,1,99) DO domain –create mydomain61%i.INFO -login user61%i -ip IP_address -status enabled -hosting true -hst_type phys -passwd domainpass -cgi true -php true -dns true -template Default_Domain

Note that you have to add your own template and rename it like Default_Domain. Of course you can script this even more by taking the domains from a list, same for the ip addresses.

On Linux this can be done using the domain.sh script.

Install FFmpeg and FFmpeg-php on Centos 5 and Plesk

Run :

rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
yum -y install ffmpeg ffmpeg-devel mplayer mencoder flvtool2
cd /usr/src
Download http://garr.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.6.0.tbz2
tar jxvf ffmpeg-php-0.6.0.tbz2
cd ffmpeg-php-0.6.0
phpize
./configure
make
make install

Edit /etc/php.ini and add :

extension=ffmpeg.so

and then:

service httpd restart

Plesk Qmail issue regarding /etc/courier-imap/shared/index

If you see in your logs:
Jun 4 16:11:18 host imapd: /etc/courier-imap/shared/index: No such file or directory

you need to check perms and ownership on /var/qmail/bin/qmail-queue

# ls -la /var/qmail/bin/qmail-queue
-r-s–x–x 1 root qmail 25828 Apr 26 15:20 /var/qmail/bin/qmail-queue
perms are fine, but ownership is not
# chown qmailq:qmail /var/qmail/bin/qmail-queue
# ls -la /var/qmail/bin/qmail-queue
-r-x–x–x 1 qmailq qmail 25828 Apr 26 15:20 /var/qmail/bin/qmail-queue
[root@host ~]# service qmail restart
Stopping : Starting qmail: