mikaku / Monitorix

Monitorix is a free, open source, lightweight system monitoring tool.
https://www.monitorix.org
GNU General Public License v2.0
1.12k stars 167 forks source link

Access Monitorix using nginx reverse proxy - Images/Graphs not shown #205

Closed JoergBerlin closed 6 years ago

JoergBerlin commented 6 years ago

Hi,

I installed Monitorix and it works fine.

As next step, I tried to access Monitorix using nginx reverse proxy https://mydomain/monitorix/

The Start Page is loading and I can choose Hostname, Graph, Period. When I click "ok", the next page opens with the following url:

https://mydomain/monitorix-cgi/monitorix.cgi?mode=localhost&graph=all&when=1day&color=black

But all graphs are not shown. Only thumbnails. By mouse over, it shows me the following:

javascript:void(window.open('https://127.0.0.1:87/monitorix/imgs/system1z.1day.png','','width=897,height=370,scrollbars=0,resizable=0'))

If I click on a thumbnail, it opens a new window and shows the following:

"Die Webseite unter https://127.0.0.1:87/monitorix/imgs/system1z.1day.png ist möglicherweise vorübergehend nicht verfügbar oder wurde dauerhaft an eine neue Webadresse verschoben. ERR_UNSAFE_PORT"

I did following nginx configuration

nginx gateway file (/etc/nginx/conf.d/mydomain.conf):

        location ^~ /monitorix {
                proxy_pass http://127.0.0.1:87;
                proxy_redirect off;
        }

nginx virtual host config-file (/etc/nginx/conf.d/mydomain_monitorix.conf:

server {
        listen 87;
        server_name 127.0.0.1:87 default_server;

location  /monitorix {
  include proxy_params;
  proxy_pass         http://127.0.0.1:8080;
  allow 127.0.0.0/8;
  location ~^ /monitorix/(.+\.png)$ {
  alias /var/lib/monitorix/www/$1;
  }
  access_log /var/log/nginx/monitorix.access.log
  error_log /var/log/nginx/monitorix.error.log
}
}

Whyt do I have to change in my configuration to successfully access Monitorix using nginx reverse proxy?

Thanks so much.

Joerg Beginner

mikaku commented 6 years ago

I don't use Nginx so excuse my ignorance. Does your Nginx server is listening on port 87 or 80? it's not clear to me after seeing your configuration snippets.

Also, I'd recommend you to take a look at the option called url_prefix_proxy. It might be of help to you.

Just let me know.

JoergBerlin commented 6 years ago

so du u prefer apache? For me it doesn´t matter ... Nextcloud (my main duty) will also run with apache and so I could change

That´s the relevant part of the config:

nano /etc/nginx/conf.d/jmr.ddnss.eu.conf

server {
        listen 443 ssl http2;
        server_name myserver.eu 192.168.178.230;
....
        location ^~ /monitorix {
                proxy_pass              http://127.0.0.1:87;
        }
}
mikaku commented 6 years ago

... and the url_prefix_proxy option?

JoergBerlin commented 6 years ago

the built in server ist set to diabled

<httpd_builtin>
        enabled = n

so the url_prefix_proxy in this section won´t take effect, so I guess ... anyway, it is not set

Referenced to it is only needed with apache and I use nginx

mikaku commented 6 years ago

That option doesn't have anything to do with the HTTP you are using.

JoergBerlin commented 6 years ago

ok, I tried but It doesn´t work. Thanks to all here but I give up with this situation. I think, apache is more documented and for my case, the performance difference between nginx and apache doesn´t count. I try to set up a new raspy with apache and will try again to install monitorix. So again, thx to all. I close this thread ...

rotrials commented 5 years ago

Hello, sorry but I cannot find url_prefix_proxy in the /etc/monitorix/monitorix.conf

As far as I understand the nginx does not work because of the link. And with the monitorix.cgi will be bypassed.

mikaku commented 5 years ago

check the documentation.

rotrials commented 5 years ago

I did that, the only part is:

"url_prefix_proxy This option forces monitorix.cgi to bypass the URL building. This is specially usefull when Monitorix is used behind a reverse proxy. An example would be: http://myexternalwebsite.com Default value:"

but I cannot find the url_prefix_proxy in the .config file

mikaku commented 5 years ago

It's a global option, you can place it in the first group of options, the group that starts with the option title and ends with include_dir.

mikaku commented 5 years ago

There are some options that I haven't included in the configuration file. A few, but there are some. :-)

rotrials commented 5 years ago

and should I set it like: url_prefix_proxy = y ? or which are the options? Thank you

mikaku commented 5 years ago

The option expects an URL, as the documentation says.

rotrials commented 5 years ago

Auch, sorry, my mistake... I will try

rotrials commented 5 years ago

Could you provide some details about how you test it? because my graphs are not loading :(

mikaku commented 5 years ago

I don't know very well. I've never used that option, someone requested it and probably, in some way, I tested it and found it interesting.

Check the FAQ about it here.

Although I see now that it looks like you can include it in the HTTP built-in server!

loskael commented 3 years ago

https://www.monitorix.org/documentation.html#https_url