我通过Kubernetes上的NGINX docker容器为我的反应应用程序提供了一些问题。
终点还活着,我可以看到它加载了它的资源......但就是这样。它不会渲染任何东西。这是Dockerfile:
FROM node:8.1.0-alpine AS builder
RUN mkdir /home/app
WORKDIR /home/app
COPY package.json .
RUN npm install
COPY . .
RUN npm run build
# ---- Base Release Image
FROM nginx:1.13.1-alpine
COPY ./config/nginx/default.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /home/app/build /usr/share/nginx/html
以下是我用于NGINX的default.conf:
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location /admin {
alias /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
#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;
#}
}
如果在/之外的任何其他路径中使用它,它不会渲染。一旦我在任何相对路径上提供服务,即使它加载了内容,它也会崩溃。
我不知道还有什么可以尝试。