I am trying to deploy an angular based webapp to kube, I am trying to deploy it as static content using nginx.
The problem is the URL's are not accessible; meaning if I try to access https://website.company.com/route1, I get a 404 not found error, I can access https://website.company.com and then click on route1 from homepage it takes me to https://website.company.com/route1
Any guidance on what am I missing here?
Following are my Dockerfile and nginx.conf.erb
Dockerfile:
FROM nginx
EXPOSE 80
COPY www/* /usr/share/nginx/html
COPY nginx.conf.erb /etc/nginx/nginx.conf.erb
nginx.conf.erb:
worker_processes 1;
error_log stderr;
pid /app/.nginx-tmp/pid;
daemon off;
events {
worker_connections 768;
}
http {
include mime.types;
client_body_temp_path /app/.nginx-tmp/body 1 2;
proxy_temp_path /app/.nginx-tmp/cache 1 2;
fastcgi_temp_path /app/.nginx-tmp/fastcgi 1 2;
uwsgi_temp_path /app/.nginx-tmp/uwsgi 1 2;
scgi_temp_path /app/.nginx-tmp/scgi 1 2;
access_log off;
server {
listen <%= ENV['PORT'] %>;
server_name _;
root /app/www;
index index.html;
location = /__health {
return 200 'OK';
add_header Content-Type text/plain;
}
location / {
try_files $uri $uri/ /index.html;
}
}
}
UPDATE:
Dockerfile:
FROM nginx
RUN mkdir -p /app/.nginx-tmp
COPY www/* /usr/share/nginx/html
COPY nginx.conf /etc/nginx/nginx.conf
nginx.conf
worker_processes 1;
error_log stderr;
pid /app/.nginx-tmp/pid;
events {
worker_connections 768;
}
http {
include mime.types;
client_body_temp_path /app/.nginx-tmp/body 1 2;
proxy_temp_path /app/.nginx-tmp/cache 1 2;
fastcgi_temp_path /app/.nginx-tmp/fastcgi 1 2;
uwsgi_temp_path /app/.nginx-tmp/uwsgi 1 2;
scgi_temp_path /app/.nginx-tmp/scgi 1 2;
access_log off;
server {
listen 80;
server_name _;
root /app/www;
index index.html;
location = /__health {
return 200 'OK';
add_header Content-Type text/plain;
}
location / {
try_files $uri $uri/ /index.html;
}
}
}
Error:
2020/12/18 01:43:53 [error] 31#31: *2 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 172.17.0.1, server: _, request: "GET / HTTP/1.1", host: "localhost:8080" 2020/12/18 01:43:53 [error] 31#31: *1 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 172.17.0.1, server: _, request: "GET /favicon.ico HTTP/1.1", host: "localhost:8080", referrer: "http://localhost:8080/"