Docs: Bookmark/Arch/NGINX
location /<path> {
root <html/static/file/location>;
index index.html;
try_files $uri $uri/ /index.html =404;
}
NOTE: Nginx try_files directive recursively searches for files and directories specified from left to right until it finds ones. Specifying this directive in the location / can cause performance issues, especially on sites with massive traffic. Therefore, you should explicitly specify the location block for try_files.
location /epo {
rewrite ^/epo/(.*) /$1 break;
proxy_pass <http://frontend:8080>;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded_For $proxy_add_x_forwarded_for;
}
location /epo/api/ {
proxy_pass <http://backend:8080/>;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
Bao gồm các cấu hình tương ứng với URI. location [modifier] path { # Các cấu hình }
Các modifier và thứ tự ưu tiên:
= - Match chính xác
^~ - Match ưu tiên
~ && ~* - Match regex (* để không phân biệt chữ hoa)
Để trống - Match tiền tố
rewrite /index_page /index.html;
rewrite /about_page /about.html;
location = /index_page {
return 307 /index.html;
}
location = /about_page {
return 307 /about.html;
}