YunoHost-Apps / garradin_ynh

Logiciel libre de gestion associative pour YunoHost
https://garradin.eu/
GNU General Public License v3.0
7 stars 8 forks source link

Sites sous garradin HS depuis MAJ Yunohost #24

Closed emiliien closed 3 years ago

emiliien commented 4 years ago

Hi ! Since the last Yuno update, all my garradin websites are reachables, but when I clic on a link,a file is downloaded .... nothing more the file :

<?php
namespace Garradin;
require __DIR__ . '/_inc.php';
if (Config::getInstance()->get('desactiver_site'))
{
    Utils::redirect(ADMIN_URL);
}
$squelette = new Squelette;
$squelette->dispatchURI();

Have you an idea ? it's strange ... before, everything worked fine !

Thanks a lot / Merci.

rodinux commented 4 years ago

You find a new bug... Is it only the links from the site which have this issue ? Can you also open a request on the the Yunohost forum to help you ?

rodinux commented 4 years ago

Do you mean when you click on a link edited in you're wiki page ? Like [[Title or whatever | http://domain_name.tld]] ? I can't reproduce you're issue...

emiliien commented 4 years ago

Hello ! So sorry for my late response . You can check here : https://apie-escalquens.fr hum i 'ww try to make some logs this weekend. Thank's a lot. i

Le dim. 5 juil. 2020 à 16:22, Robles Rodolphe notifications@github.com a écrit :

Do you mean when you click on a link edited in you're wiki page ? Like [[Title or whatever | http://domain_name.tld]] ? I can't reproduce you're issue...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/YunoHost-Apps/garradin_ynh/issues/24#issuecomment-653894981, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG3HCTOWIVTVS6GCWHXX2L3R2CEBTANCNFSM4OM2T2OQ .

bohwaz commented 4 years ago

First result on Google for "nginx try_files php" gives the answer: https://stackoverflow.com/questions/23917213/nginx-try-files-does-not-pass-to-php

so nginx find PHP file and process it in context of location / therefor just serve it as static file. Only last parameter is different, it's not checked but nginx make internal redirect (if it's uri) or return error code (if it's =code).

So the nginx config should be:

  index index.php index.html;
  try_files $uri $uri/ /_route.php;

I just installed an instance with nginx and Garradin and it works like that.

rodinux commented 4 years ago

Thanks for the answer. But it still not resolve the issue at once...

TheCapsLock commented 3 years ago

That did the trick for me with "Facturation" to access /admin/plugin/facturation/ but it does not work for any other pages like

TLDR ; NGINX configuration is broken

bohwaz commented 3 years ago

I think that you need to add $query_args as following:

try_files $uri $uri/ /_route.php?$query_args
rodinux commented 3 years ago

Hello, finally @ericgaspar found a solution to repair the links in the public page. correct nginx.conf This was the solution:

try_files $uri $uri/ __PATH__/__PATH__/_route.php?$query_string;

  location ~ \.php$ {
        if (!-e $request_filename) {
            rewrite ^__PATH__/?(.*)$ __PATH__/_route.php?/$1 last;
            break;
        }
        fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param REMOTE_USER $remote_user;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param SCRIPT_FILENAME $request_filename;
  }

I have alredy tested and it works ! I have push the code on the testing branch.

rodinux commented 3 years ago

@emiliien, if you still viewing this thread, can you try update your application with the testing branch ? Expecting you have done an upgrade and a migration on your server to Yunohost 4.0 and Debian 10 Buster before... With this command connected with ssh

sudo yunohost app upgrade garradin -u https://github.com/YunoHost-Apps/garradin_ynh/tree/testing --debug

Anyway, I pushed the testing branch on the stable branch. If you have upgraded to Yunohost 4, you will see the upgrade...

Sorry, I have just realize you have switch to a Drupal cms...

bohwaz commented 3 years ago

If I read the config correctly it is not using www as the document root, this is not recommended, and actively discouraged! Please don't do that.

rodinux commented 3 years ago

If I read the config correctly it is not using www as the document root, this is not recommended, and actively discouraged!

You must not have correctly read the config. It is still using an alias pointing to the www folder.

Here is it:

location __PATH__/ {

  # Path to source
  alias __FINALPATH__/www/ ;

  if ($scheme = http) {
    rewrite ^ https://$server_name$request_uri? permanent;
  }

  location ~ 403 {
    rewrite ^(.*)$ /include/ redirect;
    rewrite ^(.*)$ /cache/ redirect;
    rewrite ^(.*)$ /plugins/ redirect;
    rewrite ^(.*)$ /templates/ redirect;
    rewrite ^(.*)$ /.*.sqlite redirect;
    rewrite ^(.*)$ /.*.log redirect;
    rewrite ^(.*)$ /(README|VERSION|COPYING) redirect;
    rewrite ^(.*)$ /config\.(.*)\.php redirect;
    }

  index index.php /_route.php;

  try_files $uri $uri/ __PATH__/__PATH__/_route.php?$query_string;

  location ~ \.php$ {
        if (!-e $request_filename) {
            rewrite ^__PATH__/?(.*)$ __PATH__/_route.php?/$1 last;
            break;
        }
        fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param REMOTE_USER $remote_user;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param SCRIPT_FILENAME $request_filename;
  }

  # Increase size limit
  client_max_body_size 2M;

  # Include SSOWAT user panel.
  include conf.d/yunohost_panel.conf.inc;
}
bohwaz commented 3 years ago

OK then if that's right this part is useless:

  location ~ 403 {
    rewrite ^(.*)$ /include/ redirect;
    rewrite ^(.*)$ /cache/ redirect;
    rewrite ^(.*)$ /plugins/ redirect;
    rewrite ^(.*)$ /templates/ redirect;
    rewrite ^(.*)$ /.*.sqlite redirect;
    rewrite ^(.*)$ /.*.log redirect;
    rewrite ^(.*)$ /(README|VERSION|COPYING) redirect;
    rewrite ^(.*)$ /config\.(.*)\.php redirect;
    }
rodinux commented 3 years ago

Ok, I was not sure for these lines, it was test to protect some sensible directories. But they are perhaps useless, I agree with you. Also, I thinking about close this issue...

emiliien commented 3 years ago

Ok. ok I'll try to update if it's ok for both of you ?

rodinux commented 3 years ago

Ok. ok I'll try to update if it's ok for both of you ?

For me it seems to be all right. But I understand you do not more use garradin to manage your site...

BenoitCier commented 3 years ago

Solve on current version