当使用Haproxy时,我从Angular获得空白页

发布于 2025-02-13 18:26:21 字数 1631 浏览 0 评论 0原文

我已经部署了很多应用程序,并且我使用Haproxy将其重定向到具有路径的应用程序。对于默认路径,Angular App ch-Frontend:80可以正常工作,但是另一个Angular应用程序我获得了一个空白页。这是haproxy的配置:

global
    daemon
    maxconn 2048
    log stdout format raw local0 debug
    # tune.ssl.default-dh-param 2048

defaults
    log global
    mode http
    option forwardfor
    option http-server-close
    timeout connect 5000ms
    timeout client 300000ms
    timeout server 300000ms

frontend www-http
    bind *:80
    # bind *:443 ssl crt /usr/local/etc/haproxy/test.pem
    #http-request redirect scheme https unless { ssl_fc }

    #http-request add-header X-Proto https if { ssl_fc }
    
    use_backend api_laravel if { path_beg /main/ }
    use_backend front_encuestas if { path_beg /clinica/ }
    use_backend api_analitica if { path_beg /api-analitica/ }   
    default_backend checktime_front
    
backend checktime_front
    server checktime_front1 ch-frontend:80 maxconn 32

backend api_laravel
    mode http
    server api_laravel1 ch-backend:80/main maxconn 32

backend front_encuestas
    mode http
    #http-request set-path "%[path,regsub(^/clinica/,/,)]"
    server front_encuestas1 ch-frontend-encuestas:80 maxconn 32

backend api_analitica
    mode http
    http-request set-path "%[path,regsub(^/api-analitica/,/,)]"
    server api_analitica1 ch-api-analitica:8080/ maxconn 32

但是,当尝试获取应用程序时,我会得到这个:

<<<< img src =“ https://i.sstatic.net/tr3tk.png” alt =”输入图像在这里说明“> 如果尝试直接访问没有Haproxy的容器,则应用程序可以正常运行。

有人可以解释我会发生吗?

I have a lot application deployed, and I use HAproxy for redirect to apps with the path. For the default path the angular app ch-frontend:80 works fine, but the other angular app I get a blank page. this is the configuration for HAproxy:

global
    daemon
    maxconn 2048
    log stdout format raw local0 debug
    # tune.ssl.default-dh-param 2048

defaults
    log global
    mode http
    option forwardfor
    option http-server-close
    timeout connect 5000ms
    timeout client 300000ms
    timeout server 300000ms

frontend www-http
    bind *:80
    # bind *:443 ssl crt /usr/local/etc/haproxy/test.pem
    #http-request redirect scheme https unless { ssl_fc }

    #http-request add-header X-Proto https if { ssl_fc }
    
    use_backend api_laravel if { path_beg /main/ }
    use_backend front_encuestas if { path_beg /clinica/ }
    use_backend api_analitica if { path_beg /api-analitica/ }   
    default_backend checktime_front
    
backend checktime_front
    server checktime_front1 ch-frontend:80 maxconn 32

backend api_laravel
    mode http
    server api_laravel1 ch-backend:80/main maxconn 32

backend front_encuestas
    mode http
    #http-request set-path "%[path,regsub(^/clinica/,/,)]"
    server front_encuestas1 ch-frontend-encuestas:80 maxconn 32

backend api_analitica
    mode http
    http-request set-path "%[path,regsub(^/api-analitica/,/,)]"
    server api_analitica1 ch-api-analitica:8080/ maxconn 32

but when try get the app angular ch-frontend-encuestas I get this:

enter image description here
If try access directly to container without HAproxy the app works OK.

Someone Can explain me that happen please?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

桃气十足 2025-02-20 18:26:21

这个问题不是在Haproxy配置中,而是在Angular项目的构建中。因此,我解决了添加的问题 - base-href / path_app / ng构建中

The problem wasn't in the haproxy configuration but that in the build of Angular project. So, I resolve the problem adding --base-href /path_app/ in ng build

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文