I am running a Plesk Parallels Panel (v. 11.0) on a Ubuntu 12.04 LTS with PrestaShop (v. 1.5.3) combined with a nginx webserver (v. 1.3.0) as a reverse proxy server.

Be aware, that in any other case the solution presented here might not work for you!

One of my friends (Sven Fennema) is running Presta Shop on my server to sell his beautiful pictures to the world. When I moved to nginx as a reverse proxy server in a Plesk Parallels environment, we recognized that Presta Shop is running into troubles with a „502 Bad Gateway“ error.

First I added error logging to the „/var/www/vhosts/shop.YOURDOMAIN.TLD/conf/last_nginx.conf“, what brought me to the following error:

2013/01/05 03:10:20

[error] 31522#0: *118 upstream sent too big header while reading response header from upstream, client: IP, server: shop.YOURDOMAIN.TLD, request: „POST /de/authentifizierung HTTP/1.1“, upstream: „http://SERVER:PORT/de/authentifizierung“, host: „shop.YOURDOMAIN.TLD“, referrer: „http://shop.YOURDOMAIN.TLD/language/authentifizierung?back=my-account“

This error is (, just shortly summarizing the problem look up in the web) because of very large Cookie files (because they are encrypted using Blowfish algorithm) generated by the shop engine. As there might be more shops that I am hosting in the near future I was searching for a general solution approach and not a „fast hack“.

After figuring out for a while, finally the solution is quite simple.

Just edit your nginxDomainVirtualHost.php like presented below.

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Accel-Internal /internal-nginx-static-location;

#<s - begin edit>
# Error Log not needed anymore, when the "large Cookie problem" is solved
#error_log /PATH/TO/LOGFILE notice;
proxy_buffers 16 16k;
proxy_buffer_size 32k;
fastcgi_buffer_size 32k;
fastcgi_buffers 16 12k;
#</s - end edit>

 

In Plesk 11, you can find the file I was editing at „/usr/local/psa/admin/conf/templates/default/domain/nginxDomainVirtualHost.php“

Another option, just to enable this settings for one host would be to just edit the nginx config file of your shop domain

/var/www/vhosts/shop.YOURDOMAIN.TLD/conf/last_nginx.conf

and after that lock it in the system:

chattr +i last_nginx.conf

But of course, this solution is not very elegant. 🙂

After editing the files you have to run the httpdmng of Plesk Parallels to get the config files updated.

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

or for just one host:

/usr/local/psa/admin/sbin/httpdmng –reconfigure-domain shop.YOURDOMAIN.TLD