Answer the question
In order to leave comments, you need to log in
How to correctly register locations in Nginx?
There are 2 entities: landing and SPA. It is necessary that by going to the address http://127.0.0.1
landing files are given, and by any other ( http://127.0.0.1/sing-in
etc.) SPA files.
Stuck on the following:
server {
listen 80;
server_name localhost;
index index.html;
location = / {
root C:\Workspace\landing;
}
location ~ ".+" {
alias C:\Workspace\frontend\dist\app-frontend;
try_files $uri $uri/ /index.html;
}
}
http://127.0.0.1
), SPA files are given, i.e. the first location fails.
Answer the question
In order to leave comments, you need to log in
nginx.org/ru/docs/http/ngx_http_index_module.html#index
Keep in mind that when using an index file, an internal redirection is made and the request may be processed in another location. For example, in this configuration:
location = / { index index.html; } location / { ... }
the request for “/” will actually be processed in the second location as “/index.html”.
location = /
try_files is needed instead of index. server {
listen 80;
server_name localhost;
index index.html;
root C:/Workspace/landing;
location = / {
try_files /index.html =404;
}
location /images/ { }
location /css/ { }
location /js/ { }
location / {
root C:/Workspace/frontend/dist/app-frontend;
try_files $uri $uri/ /index.html;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question