#[SOLVED] 403 Error on mainsail.local // nginx error 13 permission denied

1 messages ยท Page 1 of 1 (latest)

stone drum
#

Hi guys,
I just finised installing Klipper / Mainsail on my setup and http://<printer_ip>/printer/info shows state "ready", so im pretty sure, the setup is fine. Only problem is that my web interface doesn't work properly. i get a 403 error. I think the problem is that nginx can't access the ~/pi/mainsail data, but i dont have enough experience with nginx to set those permissions. Can somebody please help me with that? I found some stuff about a www-data user but don't know anything about how that works.
Thanks in advance!

orchid zealot
#

how do you installed mainsail (or the complete system)?

stone drum
#

i used the manual install guide on top of a armbian on bananapi m2 zero

#

the permissions for ~/mainsail are 755 and 644 for files, so that should be ok i guess

orchid zealot
#

ok. than i think its a wrong path in your nginx config

#

pls post the output of:

ls -lt /home
stone drum
#

total 4
drwx------ 17 pi pi 4096 Jan 21 15:19 pi

orchid zealot
#

and then:

ls -lt /home/pi
stone drum
#

total 40
drwxr-xr-x 5 pi pi 4096 Jan 21 15:02 mainsail
drwxr-xr-x 2 pi pi 4096 Jan 21 14:04 klipper_config
drwxr-xr-x 2 pi pi 4096 Jan 21 13:41 klipper_logs
drwxr-xr-x 8 pi pi 4096 Jan 21 13:41 printer_data
drwxr-xr-x 5 pi pi 4096 Jan 15 17:47 moonraker-env
drwxr-xr-x 8 pi pi 4096 Jan 15 17:35 moonraker
drwxr-xr-x 2 pi pi 4096 Jan 15 17:31 gcode_files
drwxr-xr-x 5 pi pi 4096 Jan 15 17:09 klippy-env
drwxr-xr-x 11 pi pi 4096 Jan 15 16:16 klipper
drwxr-xr-x 7 pi pi 4096 Jan 14 16:56 kiauh

orchid zealot
#

ok. and now the content of your nginx config

#

(your file structur looks also wrong)

stone drum
#

user www-data;
worker_processes auto;
pid /run/nginx.pid;
error_log /var/log/nginx/error.log;
include /etc/nginx/modules-enabled/*.conf;

events {
worker_connections 768;
# multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;

    ##
    # Gzip Settings
    ##

    gzip on;

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

}

#mail {

# See sample authentication script at:

# http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript

# auth_http localhost/auth.php;

# pop3_capabilities "TOP" "USER";

# imap_capabilities "IMAP4rev1" "UIDPLUS";

server {

listen localhost:110;

protocol pop3;

proxy on;

}

server {

listen localhost:143;

protocol imap;

proxy on;

}

#}

orchid zealot
#

your mainsail config pls. not the generic one

stone drum
#

sites-enabled/mainsail?

orchid zealot
#

i dont know which guide you use. when this was the config file you added in your guide, then yes.

stone drum
#

i did this:

#

mkdir ~/mainsail
sudo rm /etc/nginx/sites-enabled/default
sudo ln -s /etc/nginx/sites-available/mainsail /etc/nginx/sites-enabled/
sudo systemctl restart nginx

orchid zealot
#

ok. this looks right

#

can you check your nginx log?

stone drum
#

2023/01/21 15:13:39 [crit] 4042#4042: *12 stat() "/home/pi/mainsail/favicon.ico" failed (13: Permission denied), client: IPI, server: _, request: "GET /favicon.ico HTTP/1.1", host: "IP", referrer: "http://IP/"
2023/01/21 15:13:39 [error] 4042#4042: *12 open() "/home/pi/mainsail/index.html" failed (13: Permission denied), client: IP, server: _, request: "GET /favicon.ico HTTP/1.1", host: "IP", referrer: "http://IP/"

#

these over and over for every page refresh

#

open() "/home/pi/mainsail/index.html" failed

#

stat() "/home/pi/mainsail/" failed (13: Permission denied)

orchid zealot
#

pls post the output of:

ls -lt /home/pi/mainsail
stone drum
#

total 44
-rw-r--r-- 1 pi pi 17975 Dec 10 19:29 sw.js
drwxr-xr-x 2 pi pi 4096 Dec 10 19:29 assets
-rw-r--r-- 1 pi pi 1731 Dec 10 19:29 index.html
-rw-r--r-- 1 pi pi 435 Dec 10 19:29 manifest.webmanifest
-rw-r--r-- 1 pi pi 123 Dec 10 19:29 config.json
drwxr-xr-x 2 pi pi 4096 Dec 10 19:29 fonts
drwxr-xr-x 3 pi pi 4096 Dec 10 19:29 img

#

my pi user has a password, i dont remember if this is the default, but is this a problem with this config?

orchid zealot
#

no. this should not be an issue

stone drum
#

i could try rebooting

#

maybe it magically helps

orchid zealot
#

pls post the output of:

ls -lt /etc/nginx/sites-available
stone drum
#

total 8
-rw-r--r-- 1 root root 2017 Jan 21 13:48 mainsail
-rw-r--r-- 1 root root 2412 Dec 20 10:36 default

orchid zealot
#

oh sry. wrong:

ls -lt /etc/nginx/sites-enabled
stone drum
#

lrwxrwxrwx 1 root root 35 Jan 21 13:48 mainsail -> /etc/nginx/sites-available/mainsail

#

total 0 in front

orchid zealot
#

pls upload you full nginx log

stone drum
#

the /var/log/nginx/mainsail-error.log?

orchid zealot
#

and access pls

stone drum
#

if you have any idea what the problem is, let me know please ๐Ÿ™‚

orchid zealot
#

i only have to install unzip, because it was not in this guide, but i can open the interface without issues

stone drum
#

thanks a lot for testing this again! i think i will look into this again on the weekend.

stone drum
#

The solution was to change one line in the nginx config from "user www" to "user pi". Now it works flawlessly ๐Ÿ™‚