Need help with nginx.conf and my_webapp

What type of hardware are you using: VPS bought online
What YunoHost version are you running: 11.3.0.2
What app is this about: my_webapp

Describe your issue

Hello everyone,

I’m having trouble adjusting the nginx.conf correctly for an application in my_webapp. Can anyone here give me a tip?

The application I want to install is vvveb (https://vvveb.com/).

In principle, vvveb comes with an nginx.conf that should be ‘easy’ to copy. The problem is that this nginx.conf does not fit 1:1 to the structures of YunoHost. So I have to transfer fragments of it. I can also partially get the application to run. But there is always a small hitch.

The nginx.conf can be found at Vvveb/nginx-live.conf at master · givanz/Vvveb · GitHub
The file is quite complicated. With many individual settings. I don’t understand everything 100% right away. I would therefore leave out individual parts (e.g. caching) for the time being and optimise them bit by bit.

The nginx.conf has the following line, for example:

#always use public folder as root for security
root /var/www/vvveb/public;

This collides with Yunohost’s specifications when I edit the file /etc/nginx/conf.d/mydomain.com.d/my_webapp.conf. The WebRoot is defined there by alias and not by root.

alias /var/www/my_webapp/www/;

If I run the application directly under ‘/’, I can simply use the keyword root instead of alias. This works.

root /var/www/my_webapp/www/public/;

However, if I run the application under a SubDir ‘/sub/’, then there is a problem with location /sub/ and the root …

location /sub/ {

    # Path to source
    root /var/www/my_webapp/www/public/;
    :

A my_webapp.conf that works for installed under root ‘/’ is the following:

location / {

    # Path to source
    root /var/www/my_webapp/www/public/;

    # Default indexes and catch-all
    index index.php index.html;
    try_files $uri $uri/ /index.php$is_args$args;

    # Prevent useless logs
    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    # Deny access to hidden files and directories
    location ~ ^/(.+/|)\.(?!well-known\/) {
        deny all;
    }

    include conf.d/domain.comd/my_webapp.d/*.conf;

    # Include SSOWAT user panel.
    # include conf.d/yunohost_panel.conf.inc;
}

A my_webapp.conf that half works for installed under a path ‘/sub’ is this one:

rewrite ^/sub$ /sub/ permanent;
location /sub/ {

    # Path to source

    # This works to 90% -> no Login-Location at /admin-fgat6, but only /admin
    alias /var/www/my_webapp/www/public/;
    try_files $uri $uri /sub//sub/index.php$is_args$args;

    # This works not
    # -> File not found.    
    # "GET /sub/install/index.php" 404
    # root /var/www/my_webapp/www/public/;
    # try_files $uri/ $uri /sub/index.php$is_args$args;
    
    # Default indexes and catch-all
    index index.php index.html;
  

    # Prevent useless logs
    location = /sub/favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /sub/robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    # Deny access to hidden files and directories
    location ~ ^/sub/(.+/|)\.(?!well-known\/) {
        deny all;
    }

    include conf.d/domain.com.d/my_webapp.d/*.conf;
}

The problem with the latter is that during the security check whether the document root was set to ‘public’, this was not recognised. This means that admin access can only be operated under ‘/admin’. Otherwise you could also choose ‘/admin-fgat6’.

Does anyone here have any tips on what is wrong and what I should change?

Share relevant logs or error messages

If I use root /var/www/my_webapp/www/public/; with SubDir

In /var/log/nginx/domain.com-error.log:

*6518 FastCGI sent in stderr: “Primary script unknown” while reading response header from upstream, client: 1.2.3.4, server: domain.com, request: “GET /sub/install/index.php?action=install HTTP/2.0”, upstream: "fastcgi://unix:/var/run/php/php8.3-fpm-my_webapp

in php-fpm.log
“GET /sub/install/index.php” 404

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