yonjah / piwigo_privacy

A small script and nginx configuration to increase the privacy of piwigo gallery
GNU General Public License v2.0
20 stars 8 forks source link

Video loading not supported in Advanced Mode #19

Open ollimaz opened 4 years ago

ollimaz commented 4 years ago

Hi,

the plugin doesn't support videos in Advanced Mode with Nginx.

Expected behaviour:

Current behaviour:

yonjah commented 4 years ago

Hi @ollimaz 404 sound like an issue with your nginx config. Can you post it here ? If this is an issue with the plugin and not the nginx conf check if you have any errors in php error log. You can set piwigo_privacy_debug conf to 1 to get error thrown with the actual reason for the rejection

ollimaz commented 4 years ago

Hi @yonjah,

I'm sorry for the late response... This is my config(very close to your given example): `server {

root /var/www/**censored**;

server_name **censored**;

access_log /var/log/nginx/piwigo.access.log;
error_log /var/log/nginx/piwigo.error.log ;

location / {
    try_files $uri $uri/ =404;
}

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_param  SCRIPT_NAME  $fastcgi_script_name;
    include fastcgi_params;

}

location ~ /\.ht {
    deny all;
}

#### Extra Security blocks not necessary for the plugin, just some added security ####
location ~  \.inc\.php$ {
    deny all;
}

location ~  ^/(include|install|local|tools|admin/include|admin/themes|plugins|upload|themes|galleries|_data|doc|language|template-extension)/.*\.php$ {
    deny all;
}

location ~ /\. {
    access_log off;
    log_not_found off;
    deny all;
}
#### End of extra security block ####

location ~ ^/\d+/ {
    set $script '/plugins/piwigo_privacy/get.php';
    fastcgi_pass unix:/run/php-fpm/www.sock;
    fastcgi_index  get.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$script;
    fastcgi_param  SCRIPT_NAME      $script;
    include fastcgi_params;
}

# explicitly allow piwigo_privacy get.php you don't need this rule in advance mode or if you are not
# using the extra security blocks which block all direct access to php files in plugins
location = /plugins/piwigo_privacy/get.php {
    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_param  SCRIPT_NAME  $fastcgi_script_name;
    include fastcgi_params;
}

location = /i.php {
    deny all;
}

location /upload {
    internal;
}

location /galleries {
    internal;
}

location /_data {
    internal;
}

location /_data/combined {
    try_files $uri $uri/ =404;
}

error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 421 422 423 424 425 426 428 429 431 451 500 501 502 503 504 505 506 507 508 510 511 /error.html;

location = /error.html {
    ssi on;
    internal;
    root /var/www/errordocs;
}

listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/**censored**/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/**censored**/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}`

It really seems to be a config error. But the source of the Video isn't a get.php link like with the pictures.

yonjah commented 4 years ago

Just cheked with latest Piwigo version in advance mode and videos seem to work. In advance mode you don't need the get.php file and the original URLs are being used. Make sure the path to the video actually exists in you nginx config and that the file is in the correct path on your server (should be one of the internal paths).

extorn commented 3 years ago

I hope you don't mind my adding to this. I've got the same problem when retrieving videos via the webservices call. The problem is that videos have an original_url that is missing the image id in the path. In the android app I wrote, I check for this situation and repair the url, but it shouldn't be necessary. From emails I've received, others have the same problem. I've not had chance to look at why this occurs for videos and not images, but that's the way it is. example: This is an excerpt of what is returned (incorrectly) from pwg.categories.getImages webservices call: <image id="5373" width="1920" height="1080" hit="1" file="20200828_133137.mp4" date_available="2021-01-23 15:17:40" page_url="https://myserver/piwigo/picture.php?/5373" element_url="https://myserver/piwigo/upload/2021/01/23/20210123151740-babffba8.mp4"> This is what it should look like <image id="5373" width="1920" height="1080" hit="1" file="20200828_133137.mp4" date_available="2021-01-23 15:17:40" page_url="https://myserver/piwigo/picture.php?/5373" element_url="https://myserver/piwigo/5373/upload/2021/01/23/20210123151740-babffba8.mp4"> Note the element_url now has the id of the resource between piwigo server base path and /upload.