[SOLVED] How to config frontail log with nginx?

After installing nginx for HTTPS secure access, the frontail no longer works.
How can I configure it?

http://openhabianpi:9001/

Platform information:
Hardware: Raspberry PI 3 Model B
OS: Raspbian GNU/Linux 9 (stretch)
openHAB version: openHAB 2.3.0-1 (Release Build)

This is my nginx config file:

server {
    listen                          80;
    server_name                     openHABianPi;
   
}
server {
    listen                          443 ssl;
    server_name                     mydomain.com;

    ssl_certificate                 /etc/ssl/openhab.crt;
    ssl_certificate_key             /etc/ssl/openhab.key;
    

    location / {
        proxy_pass                              http://localhost:8080/;
        proxy_set_header Host                   $http_host;
        proxy_set_header X-Real-IP              $remote_addr;
        proxy_set_header X-Forwarded-For        $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto      $scheme;
		
        satisfy                                 any;
        allow                                   192.168.0.1/24;
        allow                                   127.0.0.1;
        deny                                    all;
		
        auth_basic                              "Username and Password Required";
        auth_basic_user_file                    /etc/nginx/.htpasswd;
    }

}

I don’t know anything about it but it would seem that adding:

server {
    listen                          9001;
    server_name                     openHABianPi;
}

Should be sufficient

Thank you Vicent for your reply, i just tried this configuration but don’t works.

Just did this myself. Create a new location block in nginx:

        location /frontail {
                proxy_set_header Host                   $http_host;
                proxy_set_header X-Real-IP              $remote_addr;
                proxy_set_header X-Forwarded-For        $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto      $scheme;
                proxy_pass      http://localhost:9001/frontail;
        }

then you have to edit /etc/systemd/system/frontail.service: add --url-path /frontail to the ExecStart line:

ExecStart=/usr/bin/frontail --url-path /frontail --host 127.0.0.1 --ui-highlight --ui-highlight-preset /usr/lib/node_modules/frontail/preset/openhab.json -t openhab -l 2000 -n 200 /var/log/openhab2/openhab.log /var/log/openhab2/events.log

execute sudo systemctl daemon-reload and sudo systemctl restart frontail

Then you should be able to access frontail from mydomain.com/frontail

1 Like

I tried with this, but don’t work. When i open http://openhabianpi/frontail this message appears: 502 Bad Gateway nginx/1.10.3
This is the config file:

server {
    listen                          80;
    server_name                     openHABianPi;
	
	location /frontail {
		proxy_set_header Host                   $http_host;
		proxy_set_header X-Real-IP              $remote_addr;
		proxy_set_header X-Forwarded-For        $proxy_add_x_forwarded_for;
		proxy_set_header X-Forwarded-Proto      $scheme;
		proxy_pass								http://localhost:9001/frontail;
	}
   
}

server {
    listen                          443 ssl;
    server_name                     mydomain.com;

    ssl_certificate                 /etc/ssl/openhab.crt;
    ssl_certificate_key             /etc/ssl/openhab.key;
    

    location / {
        proxy_pass                              http://localhost:8080/;
        proxy_set_header Host                   $http_host;
        proxy_set_header X-Real-IP              $remote_addr;
        proxy_set_header X-Forwarded-For        $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto      $scheme;
		
        satisfy                                 any;
        allow                                   192.168.0.1/24;
        allow                                   127.0.0.1;
        deny                                    all;
		
        auth_basic                              "Username and Password Required";
        auth_basic_user_file                    /etc/nginx/.htpasswd;
    }
}

and this is the config in:

/etc/systemd/system/frontail.service

[Unit]
Description=Frontail openHAB instance, reachable at http://%H:9001
Documentation=https://github.com/mthenw/frontail
Documentation=https://github.com/openhab/openhabian/issues/28
After=openhab2.service

[Service]
Type=simple
ExecStart=/usr/bin/frontail --url-path /frontail --host 127.0.0.1 --ui-highlight --ui-highlight-preset /usr/lib/node_modules/frontail/preset/openhab.json -t openhab -l 2000 -n 200 /var/log/openhab2/openhab.log /var/log/openhab2/events.l$
Restart=always
User=openhab
Group=openhab
Environment=PATH=/usr/bin/
Environment=NODE_ENV=production
WorkingDirectory=/usr/bin/

[Install]
WantedBy=multi-user.target

Strange… Have you reloaded your nginx config after the change? sudo nginx -s reload. Also, make sure you test the config before using sudo nginx -t.

Yes i am sure, the sudo nginx -t give me ok

I noticed that your frontail config looks bad at the end of the ExecStart line: /var/log/openhab2/events.l$. Is that just a copy-paste error in the forum? Otherwise that probably prevents frontail from running. What does systemctl status frontail report?

In the config file is correct, it’s a copy and paste error, but you are true, the frontail not start correctly.
This is the return code next this command systemctl status frontail

● frontail.service - Frontail openHAB instance, reachable at http://openHABianPi:9001/frontail
Loaded: loaded (/etc/systemd/system/frontail.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2018-10-21 00:37:20 CEST; 7h ago

Process: 637 ExecStart=/usr/bin/frontail --url-path /frontail --host 127.0.0.1 --ui-highlight --ui-highlight-preset /usr/lib/node_modules/frontail/preset/openhab.json -t openhab -l 2000 -n 200 /var/log/openhab2/openhab.log /var/log/ope
Main PID: 637 (code=exited, status=127)

Oct 21 00:37:20 openHABianPi systemd[1]: frontail.service: Failed with result ‘exit-code’.
Oct 21 00:37:20 openHABianPi systemd[1]: frontail.service: Service hold-off time over, scheduling restart.
Oct 21 00:37:20 openHABianPi systemd[1]: Stopped Frontail openHAB instance, reachable at //openHABianPi:9001/frontail.
Oct 21 00:37:20 openHABianPi systemd[1]: frontail.service: Start request repeated too quickly.
Oct 21 00:37:20 openHABianPi systemd[1]: Failed to start Frontail openHAB instance, reachable at //openHABianPi:9001/frontail.
Oct 21 00:37:20 openHABianPi systemd[1]: frontail.service: Unit entered failed state.
Oct 21 00:37:20 openHABianPi systemd[1]: frontail.service: Failed with result ‘exit-code’.
Warning: frontail.service changed on disk. Run ‘systemctl daemon-reload’ to reload units.
Unit report.service could not be found.

Ok, then at least we have found where the error is, now we just need to figure out what it is. What happens if you just copy the entire line after ExecStart= and try to run it from the command line?

The result is: /usr/bin/env: ‘node’: No such file or directory

The result is:/usr/bin/env: ‘node’: No such file or directory

Ok, making progress. What does which node output?

Nothing…

Hmm, did it work before you made the changes to the frontail.service-file? How did you install frontail? Try reinstalling it from the openhabian-config utility, just to make sure everything gets installed correctly.

I reinstalled the frontail from openhabian-config utility, now it’s work but i not see the log in the web interface.

Can you access it from http://openhabianpi:9001?

No, i see " Welcome to nginx!", but on http://openhabianpi/frontail i see the correct web page without log.

Good! Have you re-added the --url-path-option to the frontail.service-file?

Yes, now i changed this line nginx config file:
from: proxy_pass http://localhost:9001/frontail;
to: proxy_pass http://localhost:9001;
and all work fine!! :slight_smile:
Thank you so much for the time you spent!