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

  • Home
  • SEARCH
  • 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 8721945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:18:19+00:00 2026-06-13T07:18:19+00:00

I’m creating a hybrid PHP/Node.js application. For PHP, I’m using the Yii framework. Within

  • 0

I’m creating a hybrid PHP/Node.js application. For PHP, I’m using the Yii framework. Within Node.js, I use express.

PHP is running through Nginx. I use the proxy_pass directive to funnel any request starting with /node to the Node server running on port 3000 (e.g. server.com/node/api is proxyed to server.com:3000/api.)

This works well, for the most part. However, one of the directives in my Nginx configuration file ensures that requests for non-existent static files are not passed on to Yii. Instead, a simple 404 error is returned. The original version of this directive looks like this:

location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar|txt)$ {
    try_files $uri =404;
    #For production servers you can set expires header with a long period
    expires 3M;
}

The problem with this directive is that some static files (notably the socket.io client) are served by Node.js. When the browser requests server.com/node/socket.io/socket.io.js, the above rule gets fired, and Nginx returns the 404.

What I want to do is modify the rule so that the 404 is returned only when the request for a static file is NOT preceded by /node/. I’ve tried various combinations of rules, but none of them seem to work. After consulting the perl regular expression documentation, here’s one that I thought might work, but doesn’t:

location ~* (?<!/node/)\.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar|txt)$ {
    try_files $uri =404;
    expires 3M;
}

I thought the negative/look-behind part of the rule, (?<!/node/), would work to exclude requests starting with /node/, but it doesn’t. Instead, the rule gets fired for both genuinely non-existent js files and for socket.io.js (and various other static files served from Node.js.) So in both cases I get a 404.

How should I change the regular expression so that the rule only gets applied when the request does NOT start with /node/?

  • 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-13T07:18:20+00:00Added an answer on June 13, 2026 at 7:18 am

    If I read your question right, you’re talking about paths that don’t start with /node/. That’s a lot simpler than matching something that’s not preceded by something. This should do it:

    location ~* ^(?!/node/).*\.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar|txt)$ {
    

    I think @Pogo almost had it, but as I understand it location doesn’t include the server name. The regex start anchor, ^, matches the position immediately after .com (in this case) and before the first slash. Thus, ^(?!/node/) ensures that your path doesn’t start with /node/.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

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.