【发布时间】:2020-01-22 18:25:42
【问题描述】:
所以我面临的问题非常令人沮丧,因为我不清楚问题是什么。我会尽我所能描述它。
我有一个在 Azure 中运行的 Kubernetes 集群。我有两个组件正在运行,一个是 nginx 入口负载均衡器,另一个是也在 nginx 服务器上运行的反应应用程序。这两个服务都在自己的 pod 上运行。负载均衡器通过 HTTPS 将流量引导到我的反应应用程序。
在此实现之前,我将 React 应用程序直接暴露在互联网上。这很好用,没有任何问题,因为我正在使用负载均衡器,我的反应应用程序不再工作了。
错误的意思是 js 和 css 文件是用 index.html 代码加载的,所以这就是我的 react 应用程序无法加载的原因。我试图弄清楚为什么会发生这种情况,但没有任何成功。我还检查了服务器上的文件,它们没有显示 index.html 文件的内容。他们正在显示我的 react 构建中出现的内容,这是正确的。
这是我的 nginx 配置文件:
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
我的html文件夹的内容:
希望有人可以帮助我,在此先感谢,如果您需要更多信息,请告诉我。
【问题讨论】: