Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Setting up behind reverse proxy at /pgwatch/, /pgwatch/grafana requires modifying all static file paths in html. #716

@Teut2711

Description

@Teut2711

Hi, I am setting Pgwatch up behind a reverse proxy with nginx as follows.

Main dashboard:

For the main dashboard running at 8080, I tried to edit the web.py by replacing line https://github.com/cybertec-postgresql/pgwatch2/blob/master/webpy/web.py#L446
with
cherrypy.quickstart(Root(), "/pgwatch", config=config)

The dashboard opens at https://myhost.com/pgwatch but when I inspect the html in browser, I get this.
image

To what I know about web, the base url is attached to the /static/bootstrap-4.3.1-dist/css/bootstrap.min.css to form
{base_url}/static/bootstrap-4.3.1-dist/css/bootstrap.min.css to get the css file but what the expectation is that the css file should be requested from {base_url}/pgwatch/static/bootstrap-4.3.1-dist/css/bootstrap.min.css.
So one way to fix this is to change all the href's in the html file. But that isn't a good solution.

Grafana:

Also I changed root_url in

/usr/share/grafana/conf/defaults.ini

to

root_url = %(protocol)s://%(domain)s:%(http_port)s/pgwatch/grafana . For grafana, this didn't work. I got 502.

My nginx.conf file looks like this.

server {

  # listen 80;
  listen 443 ssl;
...
  ssl_protocols TLSv1.2 TLSv1.3;
  ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
  ssl_prefer_server_ciphers off;

  ssl_dhparam /etc/dh/nginx.pem;


  location /pgwatch/grafana {
    proxy_pass http://pgwatch:3000;
    proxy_http_version 1.1;
    proxy_set_header Host $http_host;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";

  }
  location /pgwatch {
    proxy_pass http://pgwatch:8080;
    proxy_http_version 1.1;
    proxy_set_header Host $http_host;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";

  }

}

Please help with both the problems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions