# Need help with nginx.conf and my\_webapp

**URL:** https://forum.yunohost.org/t/need-help-with-nginx-conf-and-my-webapp/31944
**Category:** Support apps
**Tags:** my\_webapp, english, deutsch
**Created:** [November 11, 2024, 9:32am UTC](https://forum.yunohost.org/t/need-help-with-nginx-conf-and-my-webapp/31944 "2024-11-11T09:32:57Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![tinder](https://forum.yunohost.org/user_avatar/forum.yunohost.org/tinder/32/11441_2.png) [@tinder](https://forum.yunohost.org/u/tinder)
#### Post date: [November 11, 2024, 9:32am UTC](https://forum.yunohost.org/t/need-help-with-nginx-conf-and-my-webapp/31944/1 "2024-11-11T09:32:57Z")

</div>

**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/](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](https://github.com/givanz/Vvveb/blob/master/nginx-live.conf)  
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:

```auto
#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.

```auto
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.

```auto
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 …

```auto
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:

```auto
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:

```auto
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](http://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

---

<div class="post-metadata">

### Author: ![system](https://forum.yunohost.org/uploads/default/original/2X/f/f59fe8e3ee6b100b4f574d30d6e30479c68b89f0.png) [@system](https://forum.yunohost.org/u/system)
#### Post date: [November 26, 2024, 9:33am UTC](https://forum.yunohost.org/t/need-help-with-nginx-conf-and-my-webapp/31944/2 "2024-11-26T09:33:55Z")

</div>

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