当使用Haproxy时,我从Angular获得空白页
我已经部署了很多应用程序,并且我使用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:
If try access directly to container without HAproxy the app works OK.
Someone Can explain me that happen please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个问题不是在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