Frontail not Loading properly with NGINX

Hey guys,

So I am trying to set up Frontail with Reverse Proxy with NGINX and it seems to half work. It shows something but not the whole thing.

I followed the recommendation from [SOLVED] How to config frontail log with nginx?

I also updated the config in /etc/systemd/system/frontail.service to (also change host ip to the IP of the Pi)

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

I can reach http://192.168.2.10:9001 Just fine and shows all the graphics and everything.

Here is my config File: I have tried http://192.168.2.10:9001/;

location /frontail/ {
        proxy_pass                              http://192.168.2.10:9001/;
        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.1.0/24;
        allow                                   192.168.2.0/24;
        allow                                   192.168.8.0/24;
        allow                                   192.168.9.0/24;
        allow                                   127.0.0.1;

        deny                                    all;
        auth_basic                              "Username and Password Required";
        auth_basic_user_file                    /etc/nginx/.htpasswd;
    }

If i try: http://localhost:9001/; in the above config

I get: 502 Bad Gateway:nginx/1.10.3

So I put the config back to the IP of the OpenHABianPi and I get the same thing from the picture above.

Any ideas for the half working Frontail?

Thanks!

Justin

@fals3illusion
I’ve been trying to do the same thing with frontail and am getting the same issue as you showed in your post above.

I have PaperUI, BasicUI & Grafana all working through NGINX OK.

Like you, I tried the various suggestions in
[SOLVED] How to config frontail log with nginx?
without success.

Did you manage to solve it yourself?

I did get it to work in the end. I followed this guide https://www.openhab.org/docs/installation/security.html
This is what I have for my config files for the portion of the frontail part of my /etc/nginx/sites-enabled/openhab file.

server {
    listen                          443 ssl;
    server_name                     openhab.YOURSITENAME.com;

    ssl_certificate                 /etc/letsencrypt/live/openhab.YOURSITENAME.com/fullchain.pem;
    ssl_certificate_key             /etc/letsencrypt/live/openhab.YOURSITENAME.com/privkey.pem;
    add_header                      Strict-Transport-Security "max-age=31536000";



location /frontail/ {

        proxy_pass                              http://192.168.2.37:9001;
        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.1.0/24;
        allow                                   192.168.2.0/24;
        allow                                   192.168.9.0/24;
        allow                                   127.0.0.1;

        deny                                    all;
        auth_basic                              "Username and Password Required";
        auth_basic_user_file                    /etc/nginx/.htpasswd;

        }


    #### When using Let's Encrypt Only ####
    location /.well-known/acme-challenge/ {
        root                                    /var/www/openhab.YOURSITENAME.com;
    }
}

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

This is mine, I think mine started working once I put the actual Pi’s IP Address :

ExecStart=/usr/bin/frontail --url-path /frontail --host 192.168.2.37 --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 openhab.YOURSITENAME.com/frontail

Hope this helps you.

@fals3illusion Thanks for the update and your solution.

My setup is now ‘identical’ to yours but still not working.

On my local connection i.e. ‘http://<local IP>:9001’ I get :

Cannot GET /

From the remote connection i.e. ‘https://<remote IP>/frontail/’ I get:

502 Bad Gateway
nginx/1.14.2

I have tried various combinations of using the explicit local IP or ‘localhost/127.0.0.1’ in the NGINX proxy_pass setting and the frontail config file --host setting.
All my other NGINX services (BasicUI, PaperUI, Grafana) work OK.

I will test some more later.

Maybe try it without the port number?

https://<local IP>/frontail/

Also, I got the Cannot GET when I did only http not HTTPS

@fals3illusion
I got to the bottom of it! I had a slash ‘/’ at the end of the proxy_pass entry in my NGINX config (between the ‘1’ of ‘9001’ and the semicolon). Even though the other entries in the file have the slash and work OK it seems to cause a problem with frontail. My NGINX config frontail section now looks like this:

    location /frontail/ {
        proxy_pass                              http://localhost:9001;
        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;
    }

The ExecStart line in my frontail.service now looks like this:

ExecStart=/usr/bin/frontail --url-path /frontail --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

I didn’t need the --host 127.0.0.1 entry.

Local access to frontail has to be by an https URL:

https://<local IP>/frontail/

Remote access is similar:

https://<remote IP>/frontail/