
Ich habe eine AngularJs-App (v1), die als Docker-Image erstellt wurde (mit Nginx als Webserver). Sie hat die folgende Struktur
-app
--build
--js
|-app.min.js
|-login.min.js
--styles
|-app.min.css
|-login.min.css
--assets
--images
--fonts
--index.html
--login.html
Ich habe folgendesNginx-Konfiguration
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;
}
}
Das istHauptseiteDatei
<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>
Undanmelden.htmlDatei
<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>
Was ich erreichen möchte
Die Anzeige erfolgt , wenn Benutzer http://localhost:3000/content
die App aufrufen index.html
und login.html
wenn Benutzer sie besuchen http://localhost:3000/content/login
.
Sowohl /content
als auch /content/login
sind Routen, die in der Angularjs-App nicht vorhanden sind.
Was habe ich bekommen
Beim Aufruf http://localhost:3000/content/login
der App wurden 2 folgende Dateien geladen
http://localhost:3000/content/build/js/login.min.js
http://localhost:3000/content/build/styles/login.min.css
Beide haben den Fehlercode 404 erhalten.
Was habe ich erwartet
http://localhost:3000/content/build/js/login.min.js
Ich möchte, dass Nginx die Datei mit dem Inhalt der Datei von direkt bereitstellt http://localhost:3000/build/js/login.min.js
. Dies gilt auch für CSS-Dateien.