rogierg / rpi-checkmk

Check_mk 2.0 as a docker container for Raspberry Pi/ARM7 based on chrisss404/check-mk-arm
16 stars 4 forks source link

Rewrite when using behind reverse proxy #10

Open Pitastic opened 2 years ago

Pitastic commented 2 years ago

Hi,

first of all: Thanks for this project! I am using a fork of MeisterGig for my RPi3.

I got an nginx reverse proxy on the same machine for multiple ssl domains on that host.

When I access example.com the request is proxied to localhost:84 which is bound to checkmk-docker:5000

The problem is that in the container the request gets rewritten to 0.0.0.0:5000 which is not accessable on the proxy host and of course even not from the machine I am requesting from. The adress is changing in the browser of my device.

This is my config (certbot striped out)

server {
        server_name example.com;
        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;

        location / {
                proxy_pass http://localhost:84/;
        }
        location /websocket {;
                proxy_pass http://localhost:84/websocket;
        }
}

Are there any known configurations or fixes for that. Think it's a common use case...

Should be related to #6

Regards!

Pitastic commented 2 years ago

I am able to mitigate the problem but this is not a real fix.

I just added a rewrite rule to point every uncomplete request from example.com/ or example.com/mon/ to the complete path example.com/mon/check_mk/.

The main goal here is to rewrite the url correctly before the request reaches the conatiner where the rewrite is broken to 0.0.0.0:5000. So I leave this issue open.

Here is the complete config (the websocket seems to be unimportant):

server {
        server_name example.com;
        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;

        location / {
                rewrite ^/(mon/?)?$ /mon/check_mk/ permanent;
                proxy_pass http://localhost:84/;
        }
}