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 6836311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:20:26+00:00 2026-05-26T23:20:26+00:00

I’m currently trying out nginx and nodejs with connect running nodejs proxied in nginx.

  • 0

I’m currently trying out nginx and nodejs with connect running nodejs proxied in nginx. The problem I have is that I currently don’t run nodejs under the root (/) but under /data as nginx should handle the static requests as normal. nodejs should not have to know that it’s under /data but it seems to be required.

In other words. I want nodejs to “think” it runs at /. Is that possible?

nginx config:

upstream app_node {
    server 127.0.0.1:3000;
}

server {
...

     location /data {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_set_header X-NginX-Proxy true;

            proxy_pass http://app_node/data;
            proxy_redirect off;
    }
}

nodejs code:

exports.routes = function(app) {
    // I don't want "data" here. My nodejs app should be able to run under
    // any folder
    app.get('/data', function(req, res, params) {
            res.writeHead(200, { 'Content-type': 'text/plain' });
            res.end('app.get /data');
    });
    // I don't want "data" here either
    app.get('/data/test', function(req, res, params) {
            res.writeHead(200, { 'Content-type': 'text/plain' });
            res.end('app.get /data/test');
    });
};
  • 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-05-26T23:20:27+00:00Added an answer on May 26, 2026 at 11:20 pm

    I think this solution may be better (if you are using something like Express OR something similar that uses the “middleware” logic):

    Add a middleware function to change the url like so

    rewriter.js

    module.exports = function temp_rewrite() {
      return function (req, res, next) {
        req.url = '/data' + req.url;
        next();
      }
    }
    

    In your Express app do like so:

    app.config

    // your configuration
    app.configure(function(){
      ...
      app.use(require('./rewriter.js').temp_rewrite());
      ...
    });
    
    // here are the routes
    // notice you don't need to write '/data' in front anymore all the time
    
    app.get('/', function (req, res) {
      res.send('This is actually site.com/data/');
    });
    
    app.get('/example', function (req, res) {
      res.send('This is actually site.com/data/example')
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
I have a French site that I want to parse, but am running into
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
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 have just tried to save a simple *.rtf file with some websites and

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.