Home > Net >  "Not Found" problem with QuestDB behind NGINX
"Not Found" problem with QuestDB behind NGINX

Time:01-24

I am running a QuestDB 6.6.1-server. Now I want to increase the protection of this server and put the web gui behind an NGINX reverse proxy as described in enter image description here

It is POSSIBLE to reach the QuestDB web gui via <server.domain>:9000, no issues there.

The "location" settings are defined in a file reverse_proxy.conf:

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name server.domain;
    return 301 https://$host$request_uri;
}

server {
  listen 443 ssl;
  listen [::]:443 ssl;

  ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
  ssl_prefer_server_ciphers on;

  ssl_certificate <path>/nginx.crt;
  ssl_certificate_key <path>/nginx.key;
  
  root /var/www/server.domain/html;
  index index.html index.htm;

  server_name server.domain;

  location /location1 {
    proxy_pass https://localhost:port1;
    proxy_set_header Host $host;
  }

  location /location2 {
    proxy_pass http://localhost:port2/location2;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    client_max_body_size 10M;
  }

  location = /questdb/ {

    auth_basic "Restricted QuestDB";
    auth_basic_user_file <path>/.htpasswd;

    proxy_pass http://localhost:9000;
    proxy_set_header Host $host;
    proxy_read_timeout 300;
    proxy_connect_timeout 120;
    proxy_send_timeout 300;
    proxy_set_header Host $host;
  }
}

reverse_proxy.conf is imported into nginx.conf. nginx.conf looks like this:

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
}

http {

        ##
        # Basic Settings
        ##
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;

        # For suppression of server version number
        server_tokens off;

        server_names_hash_bucket_size 64;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##
        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##
        gzip on;
        gzip_disable "msie6";
   
        ##
        # Virtual Host Configs
        ##
        map_hash_max_size 262144;
        map_hash_bucket_size 262144;

        include /etc/nginx/conf.d/*.conf;
}

CodePudding user response:

I see you are using questdb on a directory. You are proxying to http://localhost:9000/questdb, and QuestDB is saying "Not found"

To avoid that, you would need to add a slash at the end of proxy_pass http://localhost:9000; as in proxy_pass http://localhost:9000/;

Problem then is that relative URLs (/assets, /exec...) will not work and you will need to rewrite them on nginx.

It would be probably easier to just use a subdomain rather than a directory.

update: this is the nginx config I use. As explained, relative links are broken

location  /questdb/  {
proxy_pass  http://localhost:9000/;
            index  index.html index.htm;
            auth_basic "Restricted Content";
            auth_basic_user_file /opt/homebrew/etc/nginx.htpasswd;
        }
  • Related