I have an AngularJs app (v1) that is built as a Docker image (with Nginx as webserver). It has below structure
-app
--build
--js
|-app.min.js
|-login.min.js
--styles
|-app.min.css
|-login.min.css
--assets
--images
--fonts
--index.html
--login.html
I have the following nginx config
server {
listen 80;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /usr/share/nginx/html;
location /content {
rewrite ^/content$ /index.html;
}
location /content/login {
rewrite ^/content/login$ /login.html;
}
}
This is index.html file
<html lang="en" data-ng-app="app">
<header>
<script src="build/js/app.min.js"></script>
<link rel="stylesheet" href="build/styles/app.min.css">
</header>
<body>
...
</body>
</html>
and login.html file
<html lang="en" data-ng-app="app-login">
<header>
<script src="build/js/login.min.js"></script>
<link rel="stylesheet" href="build/styles/login.min.css">
</header>
<body>
...
</body>
</html>
What I want to achieve
When users go to http://localhost:3000/content
the app will serve index.html
and login.html
if users visit http://localhost:3000/content/login
.
Both of /content
and /content/login
are routes that don't exsit on the Angularjs app.
What did I get
When accessing http://localhost:3000/content/login
the app loaded 2 following files
http://localhost:3000/content/build/js/login.min.js
http://localhost:3000/content/build/styles/login.min.css
Both of them got 404 error code.
What did I expect
I want Nginx to serve directly the file http://localhost:3000/content/build/js/login.min.js
with content of file from http://localhost:3000/build/js/login.min.js
. It also apply for CSS files.