[Packageur (moins) en herbe] Modifier config nginx

,

Bonjour à tous et toutes,

Je suis en train de travailler sur le paquet de Yellow CMS et le mettre en fonctionnement. Je bloque car au moment de l’install Yellow me demande :

Datenstrom Yellow requires rewrite support for nginx! See troubleshooting.

Mon fichier conf/nginx.conf (déjà un peu modifier) :

#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {

  # Path to source
  alias __FINALPATH__/ ;

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

### Example PHP configuration (remove it if not used)
  index index.html yellow.php;

  # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file
  #client_max_body_size 50M;

  try_files $uri $uri/ yellow.php;
  location ~ [^/]\.php(/|$) {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock;

    fastcgi_index yellow.php;
    include fastcgi_params;
    fastcgi_param REMOTE_USER $remote_user;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param SCRIPT_FILENAME $request_filename;
  }
### End of PHP configuration part

  # Include SSOWAT user panel.
  include conf.d/yunohost_panel.conf.inc;
}

Et ce que me demande Yellow CMS doc ici

server {
    listen 80;
    server_name website.com;
    root /var/www/website/;
    index index.html yellow.php;

    location /cache {
        rewrite ^(.*)$ /error break;
    }

    location /content {
        rewrite ^(.*)$ /error break;
    }

    location /system {
        rewrite ^(.*)$ /error break;
    }

    location / {
        if (!-e $request_filename) {
            rewrite ^/(.*)$ /yellow.php last;
            break;
        }
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index yellow.php;
        include fastcgi_params;
    }
}

Mais je ne sais pas comment mettre cette config à la sauce de YunoHost le fait qu’il évoque des ports 80 & 9000 veut il dire qu’il faut que dans le script d’installation (partie ci-dessous) je lui ouvre des ports ?

#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Configuring firewall..." --time --weight=1

### Use these lines if you have to open a port for the application
### `ynh_find_port` will find the first available port starting from the given port.
### If you're not using these lines:
###		- Remove the section "CLOSE A PORT" in the remove script

# Find an available 
port=$(ynh_find_port --port=8095)
ynh_app_setting_set --app=$app --key=port --value=$port

# Optional: Expose this port publicly
# (N.B. : you only need to do this if the app actually needs to expose the port publicly.
# If you do this and the app doesn't actually need you are CREATING SECURITY HOLES IN THE SERVER !)

# Open the port
# ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port

````

Merci d'avance de vos réponses

Looks like the port 9000 is the port on which php-fpm is listening.
But we’re using a socket, so you don’t need the reverse proxy on that port.

The part with the port 80 is here because this file is considered a global config file for nginx. Again here, you can drop that, we have a global config for each domain. The config for your app is specific to your app and its path only.

What really matters is probably those lines

    location /cache {
        rewrite ^(.*)$ /error break;
    }

    location /content {
        rewrite ^(.*)$ /error break;
    }

    location /system {
        rewrite ^(.*)$ /error break;
    }

Even though it does look like only security rewrite rules.

Sorry when I’m write nginx.conf like this, install failed :

#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {

  # Path to source
  alias __FINALPATH__/ ;

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

### Example PHP configuration (remove it if not used)
  index index.html yellow.php;

  # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file
  #client_max_body_size 50M;

  try_files $uri $uri/ yellow.php;
  
      location /cache {
        rewrite ^(.*)$ /error break;
    }

    location /content {
        rewrite ^(.*)$ /error break;
    }

    location /system {
        rewrite ^(.*)$ /error break;
    }
  
  location ~ [^/]\.php(/|$) {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock;

    fastcgi_index yellow.php;
    include fastcgi_params;
    fastcgi_param REMOTE_USER $remote_user;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param SCRIPT_FILENAME $request_filename;
  }

  
### End of PHP configuration part

  # Include SSOWAT user panel.
  include conf.d/yunohost_panel.conf.inc;
}

What’s for sure is that you need to have __PATH__ before each location, otherwise it’s absolute.

Then, it probably fails because nginx doesn’t like the inclusion of locate into a locate instruction.
Your rewrite rules should be either before or after the current location block.

1 Like

Apres plusieurs essais, que ce soit avant ou après le bloc location ~ [^/]\.php(/|$) {
l’installation ne permet toujours pas la réécriture… H’ai essayé avec FINALPATH ça ne fonctionne pas non plus…

Dans cette configuration l’installation se fait mais il est toujours demandé le “rewrite autours de nginx”

#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {

  # Path to source
  alias __FINALPATH__/ ;

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

### Example PHP configuration (remove it if not used)
  index yellow.php;

  # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file
  #client_max_body_size 50M;

  try_files $uri $uri/ yellow.php;


  }

    location __PATH__/cache {
        rewrite ^(.*)$ /error break;
    }

    location __PATH__/content {
        rewrite ^(.*)$ /error break;
    }

    location __PATH__/system {
        rewrite ^(.*)$ /error break;
    }

 location ~ [^/]\.php(/|$) {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock;
    fastcgi_index yellow.php;
    include fastcgi_params;
    fastcgi_param REMOTE_USER $remote_user;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param SCRIPT_FILENAME $request_filename;

  
### End of PHP configuration part

  # Include SSOWAT user panel.
  include conf.d/yunohost_panel.conf.inc;
}
`````

Si vous avez des idées n'hésitez pas, merci

Sorry, I wasn’t clear.
I mean the whole location block, location __PATH__/ {

I think the best is to put these 3 location at the beginning of the file.

Avec ta proposition, il m’affiche maintenant “file not found”. J’ai fais pas mal d’essais au dessus en dessous et rien n’a fonctionné. J’ai publié sur la branch master de mon fork ici ou j’en suis.
Si quelqu’un à une idée de la conf nginx ça serait cool. =) En ce qui me concerne je suis un peu perdu…