-1

I'm currently setting up OpenMediaVault on my Rock64 Single Board PC which is based off Debian and is configured through the web GUI running from NGINX on port 80.

I'm currently trying to install Nextcloud using NGINX, MariaDB/MySQL and PHPMyAdmin, and originally I was hoping to use Docker to install and manage them all. Unfortunately I've had nothing but problems so I reverted to installing the software from the Linux repository.

I have successfully setup a MySQL server with a user and database ready for Nextcloud and have managed to get PHPMyAdmin working on a different port 8080.

Instead of using ports I would like to use subdomains but I can't seem to get them to work. So far I have set the root directories as the following:-

/var/www/openmediavault
/var/www/phpmyadmin
/var/www/nextcloud

I would like the following subdomains:- N.B I will setup SSL at a later date once I take this over a WAN.

My NGINX is configured to use /etc/nginx/sites-available and /etc/nginx/sites-enabled

The following symbolic links will be used with respective names:-

ln -s /etc/nginx/sites-available/openmediavault-webgui /etc/nginx/sites-enabled/openmediavault-webgui
ln -s /etc/nginx/sites-available/phpmyadmin /etc/nginx/sites-enabled/phpmyadmin
ln -s /etc/nginx/sites-available/nextcloud /etc/nginx/sites-enabled/nextcloud

This is the conetents of the openmediavault-webgui file

server {
    server_name openmediavault-webgui;
    root /var/www/openmediavault;
    index index.php;
    autoindex off;
    server_tokens off;
    sendfile on;
    large_client_header_buffers 4 32k;
    client_max_body_size 25M;
    error_log /var/log/nginx/openmediavault-webgui_error.log error;
    access_log /var/log/nginx/openmediavault-webgui_access.log combined;
    error_page 404 = /404.php;
    location /404.html {
        internal;
    }
    location /extjs6/ {
        alias /usr/share/javascript/extjs6/;
        expires 2d;
        }
    location ~ ^/(css|fonts|js|images)/ {
        expires 2d;
    }
    location /favicon {
        expires 14d;
    }
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php-fpm-openmediavault-webgui.sock;
        fastcgi_index index.php;
        fastcgi_read_timeout 60s;
        include fastcgi.conf;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
    listen 80 default_server;
    include /etc/nginx/openmediavault-webgui.d/*.conf;
}

I also have a symbolic link from PHPMyAdmin's location to www directory

ln -s /usr/share/phpmyadmin /var/www/phpmyadmin

Many thanks

Will

UPDATE 10:18 03/06/2019 Here is the server block for /etc/nginx/sites-enabled/phpmyadmin server { listen 80; root /var/www/phpmyadmin; index index.php; server_name phpmyadmin.rock64.lan; location / { try_files $uri $uri/ =404; } location ~ \.php { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7-0.fpm.sock; fastcgi_index index.php; } }

UPDATE 11:25 03/06/2019 After configuring my OpenWrt router I can do a DNS lookup and http://phpmyadmin.rock64.lan is pointing to the correct IP address. However, I'm getting 502 Bad Gateway. One forum I came across mentioned setting the ownership and permissions. I've had play around with them but no change.

Under /etc/php/7.0/fpm/pool.d/ I have:

[openmediavault-webgui]
user = openmediavault-webgui
group = openmediavault-webgui

listen = /var/run/php-fpm-openmediavault-webgui.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0600

pm = ondemand
pm.max_children = 25
pm.process_idle_timeout = 10s

chdir = /

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; openmediavault php.ini settings ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Paths and Directories
php_value[include_path] = ".:/usr/share/php:/var/www/openmediavault"

; Pam Authentication Support (see /etc/pam.d)
php_value[pam.servicename] = "openmediavault-webgui";

; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
php_value[upload_max_filesize] = 25M

; Maximum size of POST data that PHP will accept.
; http://php.net/post-max-size
php_value[post_max_size] = 25M

; Do not expose to the world that PHP is installed on the server.
; http://php.net/expose-php
php_value[expose_php] = Off

; Name of the session (used as cookie name).
; http://php.net/session.name
php_value[session.name] = X-OPENMEDIAVAULT-SESSIONID

; Default timeout for socket based streams (seconds)
; http://php.net/default-socket-timeout
php_value[default_socket_timeout] = 90

; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
php_value[max_execution_time] = 90

UPDATE 09/05/2019 I have now registered the FQDN as phpmyadmin.rock64.test to eliminate any conflicts and this is registered in my OpenWrt router's DNS. I can ping the domain name and I get reply back from the statically assigned IP address (192.168.1.123) I have linked to the LAN hostname. For other testing purposes I have assigned port 8080 but neither the FQDN or accessing via http://192.168.1.123:8080 works and still results in a bad gateway 502.

server {
    listen 8080;
    root /var/www/phpmyadmin;
    index index.php index.html index.htm;
    server_name phpmyadmin.rock64.test;
    server_tokens off;
    location ~ \.php$ {
        try_files $uri +404;
#       include snippets/fastcgi-php.conf;
        include /etc/nginx/fastcgi.conf;
        include /etc/nginx/fastcgi_params;
#       fastcgi_pass unix:/var/run/php/php7-0.fpm.sock;
        fastcgi_index index.php;
        fastcgi_pass 127.0.0.1:9000;
    }
    location ~ /\. {
        access_log off;
        log_not_found off;
        deny all;

    }
}
willowen100
  • 31
  • 2
  • 10
  • Do not use arbritrary TLD such as `.lan` as you are exposing yourself to collisions. Use either the names that are defined for that purpose (see RFC2606 but typically `.example` or `.test`) or create a true domain name, in any existing TLD and then use internally as a suffix for all names. – Patrick Mevzek May 03 '19 at 16:38
  • @PatrickMevzek I have changed to the .local TLD which the system OMV (Debian) uses by default. I will need to update my router's DNS table like before. I will post back with an update once I've tested. – willowen100 May 04 '19 at 07:52
  • `.local` is used by mDNS (multicast DNS) so it is fine if you are absolutely sure no devices on your network use that protocol. Otherwise, you need another one if you want to avoid clashes. – Patrick Mevzek May 05 '19 at 15:20

2 Answers2

1

The server_name should contain fully qualified domain name, such as server_name xyz.example.com

The details are in the nginx docs.

kubanczyk
  • 13,812
  • 5
  • 41
  • 55
  • Is there a wildcard I can use for the main domain itself? At the moment I have a DHCP hostname with a suffix so all of my LAN clients are 'hostname.lan' Do I specifically have to set it's full hostname or can I use a wildcard or something else in place to pick whatever the OMV/Debian server's hostname is? I tried putting 'server_name phpmyadmin.*', restarting NGINX and all I got was server not found. – willowen100 May 03 '19 at 06:26
1

You need to create a server block for each of your domains, and have the domain name listed in server_name directive.

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63
  • Is the indentation of the server block dictated by tabs or spaces? Also as long as I set the root directory to each subdomain to the correct directory in '/var/www' does it matter the FQDN isn't also the name of the directory? – willowen100 May 03 '19 at 06:30
  • I think the the only thing that matters with the `server` block are the `{}` characters. The name of the `root` directory makes no difference. – Tero Kilkanen May 03 '19 at 06:41