My Webapp: Pointing domain to /public subfolder

My YunoHost server

Hardware: VPS bought online
YunoHost version: 11.1.18
I have access to my server : Through SSH | through the webadmin
Are you in a special context or did you perform some particular tweaking on your YunoHost instance ? : no
If your request is related to an app, specify its name and version: my_webapp v1.0~ynh13

Description of my issue

I want to install LeanTime with My Webapp. LeanTime is a PHP based app using a MySQL database. I have set it up to run on https://business-suite.domain.tld/project-mgmt . However, after uploading all files via SFTP the domain needs to point to the /public directory which was created inside the www folder on the server. How do I achieve that? Any help much appreciated.

Hello, and welcome!

You will need to log into your server on SSH and to tweak the NGINX configuration file up to the liking of LeanTime. This file is located in /etc/nginx/conf.d/business-suite.domain.tld/my_webapp.conf.

You can use the nano editor for example: nano /etc/nginx/conf.d/business-suite.domain.tld/my_webapp.conf Edit the file then save with CTRL+O and quit with CTRL+X.

If the app is simple enough, I guess it is only a matter of tweaking the alias statement to add public/ at its end, before the semicolon.

Then test that NGINX is happy with it with nginx -t, and if no error arises, reload it with systemctl reload nginx.


Thank you for the warm welcome and the hints. I did as you said. Nginx test was fine I could successfully reload it. As there were some implications with hosting the app in a subfolder I changed my setup to hosting it via a subdomain. So, my new setup looks as follows:

Hosting domain (subdomain): project-mgmt.domain.tld
Folder structure: /www/leantime/public

According to Leantime’s docs the domain needs to point to the /public directory. I have another LeanTime instance, still running on a shared host (without Yunohost) and it works flawlessly there when pointing the domain to the /public directory.

However, I couldn’t get the app to run unfortunately. Here are the results:

  1. Point alias to /public
alias /var/www/my_webapp/www/leantime/public/

This results first in a 303 redirect to /install which is correct as LeanTime wants to run the first-time installation. However, /install returns a 404 Not Found (nginx) error.

  1. Point alias to /leantime
alias /var/www/my_webapp/www/leantime/

This results in a 403 Forbidden (nginx). However, I can see the Yunohost overlay in the bottom right corner here which was not the case with the other configurations.

Does anybody have any advice for me what I can do?

For anybody else wanting to install LeanTime with My Webapp. I could solve the issue by adding 4 custom rewrite rules from the LeanTime nginx.excample.conf.

location / {

    rewrite ^/?$ /index.php?;
    rewrite ^/([^/\.]+)/?$ /index.php?act=$1;
    rewrite ^/([^/\.]+)/([^/\.]+)/?$ /index.php?act=$1.$2;
    rewrite ^/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ /index.php?act=$1.$2&id=$3;

The alias needs to point to the /public directory as such

alias /var/www/my_webapp/www/leantime/public/;

With this configuration everything works fine. :slight_smile: Thank you for pointing me in the right direction @tituspijean :pray:

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.