Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

148
Views
Nginx two angular apps

I'd like to add separated angular app under a specific path (the path should be at the end of an URL to be matched) - I want to keep both versions which are current and a new one but the new should only be available under the specified path. I tried using alias + try_files. My config:

server {
  listen 80;
  root /dir/project1
  server_name ...;

  index index.html;

  location ~ /path {
    alias /dir/project2
    try_files $uri $uri/ /index.html;
  }

The thing is that when try_files fires up, it takes the path from the root directive - not from the alias. How to fix it? I can only add I cannot use proxy_pass here and root instead of the alias does not work either as it adds paths etc.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The alias directive works differently when placed inside a regular expression location, but you should probably be using a prefix location anyway. See this document for details.

Also, the use of alias and try_files together can cause problems (see this long standing bug).

You are rewriting the URI to /index.html which is the wrong application, and should instead be /path/index.html.

Try:

location ^~ /path {
    alias /dir/project2;
    if (!-e $request_filename) {
        rewrite ^ /path/index.html last;
    }
}

See this caution on the use of if.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!