Announcement

#1 2019-07-07 03:40:37

syscrusher
Member
2019-07-07
2

Multisite and Nginx

Hello all

I thought I would be able to resolve this myself with some research and RTFMing, but after working on it for several hours I'm finally asking for help.

Initially I set up Piwigo 2.9.5 in the standard way, and it is working perfectly for me. However, I need to add the Multisite configuration to my system. I am using Nginx for this due to its improved performance and lower memory footprint than Apache, since I run on a private virtual server.

Obviously I started my research here: https://piwigo.org/doc/doku.php?id=user … tiple_site but that page has example configs only for Apache. I created what I thought was the equivalent in Nginx, but got a 404 error because Nginx was still trying to find the equivalent of /gallery1/index.php. My config (snippet) was like this:

location /gallery1 {
   alias /var/www/piwigo
}

I tried this with and without the try_files directive, and also tried replacing "alias" with "root" as was suggested on another forum post.

My current config looks like the listing below (with some private things replaced by generic placeholders); this is the latest of dozens of iterations. I'm aware /gallery1 and /gallery2 differ slightly in config; I was testing both methods. This configuration gives a 403 error because Nginx thinks http://piwigo.example.com/gallery1/ is trying to show a directory index.

I've administered Apache for years, but am comparatively new to Nginx, so this is undoubtedly config error on my part, but I'm out of ideas to fix it and haven't found anyone on the Net who's posted an example.

Code:

### Server name and log paths omitted here ###

root /var/www/piwigo;
location / {
   try_files $uri $uri/ =404;
}
location /gallery1 {
   root /var/www/piwigo;
   try_files $uri $uri/ index.php =404;
}
location /gallery2 {
   alias /var/www/piwigo;
   try_files $uri $uri/ =404;
}

location @rewrite {                                                                                                                            
   rewrite ^/picture((/|$).*)$ /picture.php$1 last;
   rewrite ^/index((/|$).*)$ /index.php$1 last;
   rewrite ^/i((/|$).*)$ /i.php$1 last;
}

# Space-delimited list of valid index files
index index.php;

location ~ ^(?<script_name>.+?\.php)(?<path_info>/.*)?$ {
   include snippets/fastcgi-php.conf;
   fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
   fastcgi_param PATH_INFO $path_info;
   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

My local/config/config.inc.php file is exactly as show on the Wiki page, modulo changing "gallery1" and "gallery2" to match my actual gallery names. I made sure to uncomment the lines for subdirectory galleries instead of hostname (e.g., piwigo.example.com/gallery1 and not gallery1.example.com).

Subset of Nginx debug log:

Code:

2019/07/07 01:09:18 [debug] 3287#3287: *1 http script var: "/gallery1/"
2019/07/07 01:09:18 [debug] 3287#3287: *1 trying to use file: "/gallery1/" "/var/www/piwigo/gallery1/"
...
2019/07/07 01:09:18 [debug] 3287#3287: *1 open index "/var/www/piwigo/gallery1/index.php"
2019/07/07 01:09:18 [debug] 3287#3287: *1 stat() "/var/www/piwigo/gallery1/index.php" failed (2: No such file or directory)
2019/07/07 01:09:18 [debug] 3287#3287: *1 http index check dir: "/var/www/piwigo/gallery1"
...
2019/07/07 01:09:18 [error] 3287#3287: *1 directory index of "/var/www/piwigo/gallery1/" is forbidden...

Thanks for any suggestions, or better yet an example Nginx config snippet if someone wouldn't mind sharing. I'm sure it's the alias part I've got wrong here.

Piwigo version: 2.9.5
PHP version: 7.0.33
MySQL version: MariaDB 10.1.38
Piwigo URL: (Still under construction, so not yet public)

Last edited by syscrusher (2019-07-07 03:47:14)

Offline

 

#2 2021-10-25 18:44:18

kinmen
Member
2018-12-17
43

Re: Multisite and Nginx

I am looking for a solution too.

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact