0

I have a localserver on which port 80 is open and serving nginx. I have kibana service running in port 5601 and portainer running in 9443

The following nginx.conf works and I can access kibana by going to http://localhost:

{
    listen 80;
    server_name localhost 127.0.0.1;

    location / 
    {
        proxy_pass          http://kibana:5601;
        proxy_set_header    X-Forwarded-For $remote_addr;
    }
}

The following nginx.conf works as well and I can reach portainer by going to https://localhost

{
    listen 80;
    server_name localhost 127.0.0.1;

    location / 
    {
        proxy_pass          https://portainer:9443;
        proxy_set_header    X-Forwarded-For $remote_addr;
    }
}

However if I were to put these two location on a single server (single conf like below I can only reach the Kibana and Portainer not working.

{
    listen 80;
    server_name localhost 127.0.0.1;

    location /kibana
    {
        proxy_pass          http://kibana:5601;
        proxy_set_header    X-Forwarded-For $remote_addr;
    }

    location /portainer
    {
        proxy_pass          https://portainer:9443;
        proxy_set_header    X-Forwarded-For $remote_addr;
    }
}

How can I merge these two locations in single server on port 80 and access both the services by going to

Portainer: https://localhost/portainer

Kibana: http://localhost/kibana

Any suggestions?

KosiB
  • 1,086
  • 1
  • 7
  • 13
  • Can you try adding a trailing slash to the locations, like `location /kibana/` and `location /portainer/`? – Geilmaker Jul 26 '23 at 09:24
  • Then you might also need to add the trailing slash to your proxy_pass, like `proxy_pass http://kibana:5601/` and `proxy_pass http://portainer:9443/`. Also make sure to change the `https` inside the `proxy_pass` of the portainer to `http`. – Geilmaker Jul 26 '23 at 09:53
  • Here is a more detailed description, why I suggest these edits. https://stackoverflow.com/questions/22759345/nginx-trailing-slash-in-proxy-pass-url – Geilmaker Jul 26 '23 at 09:54

0 Answers0