In addition, the site is sometimes inaccessible

which script are you using yeti or imagesharing
try litespeed.

2 years later

sirfpsycho
-----------------------------------
location ~ /public/ {
}
location / {
if ($http_host !~ "www."){
rewrite .*$ http://www.$http_host/$1 redirect;
}
rewrite .*$ https://$http_host$request_uri redirect;
rewrite .*$ /public/$1 break;
}