I have previously setup under Apache2 web server,
and lt.cce.academy subdomain will launch leantime application, whereas nc.cce.academy subdomain will launch Nextcloud application with no issue.
As my company prefers to use nginx, so I have installed nginx.
/etc/nginx/sites-available/lt.cce.academy config, I have the following configuration. Just to mention that this is a copy of the master configuration file from the leantime support site with a few modifications to the server name, and document root only.
------------
cat lt.cce.academy
server {
listen 80;
listen [::]:80;
server_name lt.cce.academy;
return 301 https://lt.cce.academy$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name lt.cce.academy;
set $base /var/www/cce/leantime;
root $base/public;
ssl_certificate /etc/ssl/cce.academy/cce.academy.ca-bundle;
ssl_certificate_key /etc/ssl/cce.academy/cce.academy.key;
# logging
access_log /var/log/nginx/lt_access;
error_log /var/log/nginx/lt_error warn;
# index.php
index index.php;
location ~.php$ {
# 404
try_files $fastcgi_script_name =404;
# default fastcgi_params
include fastcgi_params;
# fastcgi settings
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
fastcgi_index index.php;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
# fastcgi params
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param PHP_ADMIN_VALUE "open_basedir=$base/:/usr/lib/php/:/tmp/";
}
location / {
rewrite ^/?$ /index.php?act=dashboard.show;
rewrite ^/([^/\.]+)/?$ /index.php?act=$1;
rewrite ^/([^/\.]+)/([^/\.]+)/?$ /index.php?act=$1.$2;
rewrite ^/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ /index.php?act=$1.$2&id=$3;
}
# additional config
# favicon.ico
location = /favicon.ico {
log_not_found off;
access_log off;
}
# robots.txt
location = /robots.txt {
log_not_found off;
access_log off;
}
# assets, media
location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ {
expires 7d;
access_log off;
}
# svg, fonts
location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ {
add_header Access-Control-Allow-Origin "*";
expires 7d;
access_log off;
}
# gzip
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
}
---------
for the 2nd subdomain that suppose to launch Nextcloud, below is the config at /etc/nginx/sites-available
cat nc.cce.academy
server {
listen 80;
server_name nc.cce.academy;
root /var/www/cce/nextcloud;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/run/php/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
-----------------
nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
syntax check on configuration files are ok.
------------
At my laptop browser address box,
I keyed in "lt.cce.academy"
leantime is launched correctly.
However, when I keyed in another subdomain "nc.cce.academy",
again, leantime application is launched, and not Nextcloud application.
Lastly, when I keyed in my domain "cce.academy",
again the leantime application is launched, and not displaying the index.html at /var/cce/ directory.
I don't quite understand the config at the lt.cce.academy since I merely copy and paste and changing a few parameters.
This config must have launch Leantime application, no matter what I keyed in to the address box of my browser preventing other application like Nextcloud or index.html from running.
Need help to edit the config.
Thank you.