【问题标题】:"Not Found" problem with QuestDB behind NGINXNGINX 背后的 QuestDB 出现“未找到”问题
【发布时间】:2023-01-19 02:59:52
【问题描述】:

我正在运行 QuestDB 6.6.1 服务器。现在我想加强对该服务器的保护,并将 web gui 置于 NGINX 反向代理之后,如 QuestDB blog post where setting up basic authentication is shown 中所述。

当我尝试打开 QuestDB web gui 时,会显示登录弹出窗口,我可以毫无问题地输入名称和密码。然而,在成功通过登录弹出窗口后,我在浏览器中只看到一个纯文本“未找到”(注意:但不是 NGINX 403 未找到屏幕,我现在在其他情况下)。 nginx.log 和 questdb.log 都不显示条目。

可以通过 <server.domain>:9000 访问 QuestDB web gui,没有问题。

“位置”设置在文件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 导入到 nginx.conf。 nginx.conf 看起来像这样:

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

【问题讨论】:

    标签: nginx http-status-code-403 questdb


    【解决方案1】:

    我看到您在目录上使用 questdb。您正在代理到 http://localhost:9000/questdb,而 QuestDB 说“未找到”

    为避免这种情况,您需要在 proxy_pass http://localhost:9000; 的末尾添加一个斜杠,如 proxy_pass http://localhost:9000/;

    那么问题是相对 URL(/assets、/exec...)将不起作用,您需要在 nginx 上重写它们。

    只使用子域而不是目录可能会更容易。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-07
      • 2021-03-02
      • 2014-09-12
      • 2019-07-20
      • 2021-05-09
      • 1970-01-01
      • 1970-01-01
      • 2019-12-17
      相关资源
      最近更新 更多