简体   繁体   中英

"Not Found" problem with QuestDB behind NGINX

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 QuestDB blog post where setting up basic authentication is shown .

When I try to open the QuestDB web gui, the login popup is displayed, I can enter name and password without issues. However, after having successfully passed the login popup, I only see a bare text "Not Found" in the browser (Note: but NOT the NGINX 403 Not Found screen, which I now in other cases). Neither nginx.log, nor questdb.log show entries.

在此处输入图像描述

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;
}

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;
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM