Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8528121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:43:56+00:00 2026-06-11T08:43:56+00:00

I have a Nginx config that works fine and serves static files properly: location

  • 0

I have a Nginx config that works fine and serves static files properly:

location /static/ {
    alias /tmp/static/;
    expires 30d;
    access_log off;
}

But what I want to do now is that if the static file doesn’t exist in /tmp/static, Nginx looks for the file in /srv/www/site/static. I am not sure how to achieve that, I have tried a few things with try_files, but I don’t know how to properly use it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:43:57+00:00Added an answer on June 11, 2026 at 8:43 am

    You can set your root to the common prefix of the two paths you want to use (in this case, it’s /), then just specify the rest of the paths in the try_files args:

    location /static/ {
      root /;
      try_files /tmp$uri /srv/www/site$uri =404;
      expires 30d;
      access_log off;
    }
    

    It may seem disconcerting to use root / in a location, but the try_files will ensure that no files outside of /tmp/static or /srv/www/site/static will be served.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rewrite that nginx calls like so: location ~* (css)$ { rewrite
I have the following snippet that works fine on Heroku (production) for enforcing SSL:
I have the following location directive in my nginx config file: server{ ... location
I have a rail app that serves multiple domain_name and is deployed by nginx
I have a forum at /forum/. My nginx sites-available/ config file has a bunch
As most of my content is static i was planning to have nginx to
I have the following in nginx: # backend location /backend/ { deny all; }
I have an instance of nginx running which serves several websites. The first is
I have a Rails web app which has static files under dynamic restful urls.
Ok here is what I have already tried, on the nginx #location ~ \.lua$

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.