【问题标题】:Ngnix reverse proxy - url rewrite to avoid "localhost" from elastic enterprisesearch applicationNginx 反向代理 - url 重写以避免弹性企业搜索应用程序中的“localhost”
【发布时间】:2020-07-03 19:58:37
【问题描述】:

在 nginx 中,我将 /appsearch 映射为指向部署 Elastic AppSearch 的 localhost:3002。当我转到映射的 url http://server/appsearch 时,我看到了部分内容,内容中的 url 指向 http://server/as http://localhost/ 等。即 没有 /appsearch前缀

当我转到 http://127.0.0.1:3200 时,应用程序重定向到 http://localhost:3002/ent/select 。看起来他们硬编码了“localhost” 一些 nginx-config 可以帮助将网页中的每个资源转换为 http://server/appsearch/ ?

错误的 url 缺少前缀:http://tohulp/as 带前缀的正确网址:http://tohulp/appsearch/as

也许文档中的 url 需要重写? nginx config中怎么做?应用程序不是开源的,所以我无法更改代码,任何解决方案都必须在nginx confing中

    server {
        listen       80;
        server_name  TOHQLP;
        location /appsearch/ {
            rewrite /appsearch(.*) /$1 break;
            proxy_pass http://localhost:3002/;      
            proxy_set_header Accept-Encoding "";
    
        }

===== 应用程序将 127.0.0.1 重定向到本地主机

==== URL 重写导致 Elastic - Enterprise Search 应用程序无法正确呈现 - 也许文档中的各种 url 需要重写?如何在 nginx 配置中做到这一点?

==== 内容来源 http://tohulp/appsearch/as ====

请注意,内容有 localhost:3200,这不会获取资源。如何通过 ngnix 配置绕过/防止/解决这个问题?

【问题讨论】:

    标签: nginx


    【解决方案1】:

    您似乎正在使用企业搜索,如果您是从外部主机访问,则需要使用 ent_search.external_url 进行配置

    https://www.elastic.co/guide/en/enterprise-search/current/configuration.html

    # Define the exposed URL at which users will reach Enterprise Search.
    # Defaults to localhost:3002 for testing purposes.
    # Most cases will use one of:
    #
    # * An IP: http://255.255.255.255
    # * A FQDN: http://example.com
    # * Shortname defined via /etc/hosts: http://ent-search.search
    #
    #ent_search.external_url: http://localhost:3002
    

    【讨论】:

      猜你喜欢
      • 2020-03-13
      • 2014-02-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-22
      • 2023-03-18
      • 2014-03-24
      • 2017-04-07
      • 2020-12-18
      相关资源
      最近更新 更多