Welcome! Log In Create A New Profile

Advanced

NGINX - access files outside webroot with PHP - docker in openmediavault

Posted by compinsch 
NGINX - access files outside webroot with PHP - docker in openmediavault
September 29, 2021 04:46PM
Struggling with NGINX in Docker Linuxserver container on openmediavault development server and would appreciate some advice! Sorry if this question has been answered millions of times before but I can't seem to find an answer which I understand :(

Physical location of relevant web files on server...

volume
|__websites
.....|__content
.....|__database
..........|__connect.php
.....|__scripts
.....|__www
..........|__index.php

NGINX config

server {
..listen 80 default_server;
..listen 443 ssl;
..root /config/www;
..index index.html index.htm index.php;
..server_name omv;
..ssl_certificate /config/keys/cert.crt;
..ssl_certificate_key /config/keys/cert.key;
..client_max_body_size 0;
..autoindex on;
..location ~ \.php$ {
....fastcgi_split_path_info ^(.+\.php)(/.+)$;
....# With php5-cgi alone:
....fastcgi_pass 127.0.0.1:9000;
....# With php5-fpm:
....#fastcgi_pass unix:/var/run/php5-fpm.sock;
....fastcgi_index index.php;
....include /etc/nginx/fastcgi_params;
..}
}

Docker container maps "volume/websites/www" to "config/www" (using Portainer)

The issue is that there is a line in index.php...

require('../database/connect.php');

...which is generating an error...

Warning: require(../database/connect.php): failed to open stream: No such file or directory in /config/www/index.php on line xx
Fatal error: require(): Failed opening required '../database/connect.php' (include_path='.:/usr/share/php7') in /config/www/index.php on line xx

I never have any issues on my production server with Apache accessing files outside the webroot so I know this is a NGINX config issue but I have no idea how to solve it.

Thank you for helping.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 162
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready