nginx für statische Angular-UIs konfigurieren
English
Deutsch
Damit Angular-UIs mit nginx funktionieren, muss index.html für jede URL geladen werden, für die andernfalls ein 404 zurückgegeben würde, um das Routing zu ermöglichen:
nginx_angular_try_files.conf
location / {
try_files $uri $uri$args $uri$args/ /index.html;
}Vollständiges Beispiel für Standard-Site mit API:
nginx_angular_full.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html;
server_name MyServer;
location / {
try_files $uri $uri$args $uri$args/ /index.html;
}
location /api {
proxy_pass http://localhost:8080;
}
}Check out similar posts by category:
Nginx
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow