[Vuejs]-Nginx reverse proxy Serving Node.js app static file

0πŸ‘

βœ…

An alias statement within a regular expression location requires the full path to the file. See this document for details.

For example:

location ~* ^\/onlineAds(.*)$ {
    alias "C:/laragon/www/craiglist/dist$1";
    if (!-e $request_filename) { rewrite ^ /onlineAds/index.html last; }
}

The use of try_files with alias is avoided due to this issue. See this caution on the use of if.


Assuming that the URI /js/foo.js could be located in C:/laragon/www/laravel_App/public/js/foo.js or C:/laragon/www/craiglist/dist/js/foo.js, you could ask Nginx to try both locations using try_files with a common root directory.

For example:

location /js/ {
    root "C:/laragon/www";
    try_files /laravel_App/public$uri /craiglist/dist$uri =404;
}
location /css/ {
    root "C:/laragon/www";
    try_files /laravel_App/public$uri /craiglist/dist$uri =404;
}
πŸ‘€Richard Smith

Leave a comment