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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:09:11+00:00 2026-06-15T16:09:11+00:00

I have a node-http-proxy set up to forward site/n requests to node.js (at port

  • 0

I have a node-http-proxy set up to forward site/n requests to node.js (at port 9000), and other requests to apache (port 8000). This is because I heavily make use of socket.io, and I don’t want apache creating one thread per websocket request.

The following code works great, until I wanted to make it accessible through my public IP. Everything works except one thing – my_public_ip/n/socket.io/socket.io/js returns ‘404 Not Found’. It seems this request is not silently absorbed by node.js

httpProxy.createServer({
    router: {
        'localhost/n/': '127.0.0.1:9000',
        'localhost': '127.0.0.1:8000',
        'my_public_ip/n': '127.0.0.1:9000',
        'my_public_ip': '127.0.0.1:8000'
    }
}).listen(80);

function handler(req, res) {
    var pathName = url.parse(req.url).pathname;
    if(pathName.substr(0,2) == "//"){
        pathName = pathName.substr(1);
    }
    var pathSplit = pathName.split('/');
    nextURL = pathSplit.join('/').substr(8);
    if(pathSplit[1] == 'static'){
        fs.readFile(__dirname + '/static/' + nextURL, function(err, data) {
            if(err) {
                res.writeHead(404);
                return res.end('404 Not Found');
            }
            res.writeHead(200);
            res.end(data);
        });
    } else if(pathName !== '/'){
        fs.readFile(__dirname + '/index.html', function(err, data) {
            if(err) {
                res.writeHead(500);
                return res.end('Error loading file. Does it exist? (Reading ' + __dirname + ')');
            }
            res.writeHead(200);
            res.end(data);
        });
    }
}
  • 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-15T16:09:12+00:00Added an answer on June 15, 2026 at 4:09 pm

    The node http server is serving up the client-side script for socket.IO. What is happening is that because you are not proxying the http traffic over to node.JS, there is no way you can see the client JS script. (Socket.IO doesn’t push the JS script over a socket.IO connection.)

    The most basic work around is to create a copy of the JS script on your Apache server. Another way is to route the request to Node.JS by adding an additional routing instruction just for the script path. I think the former will give you better performance.

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

Sidebar

Related Questions

I'm running Nodejs and Apache alongside each other. node-http-proxy is listening on port 80
I'm using node.js and socket.io. I'm using http-proxy to use port 80 on a
I have node.js server which acts like a proxy. It receives requests and forwards
I have a small Node.js HTTP server that does requests to a mongo database
I'm exploring using the node-http-proxy proxy server so that I can have our proxy
We have the following example in node.js var http = require('http'); http.createServer(function(request, response) {
I have the following node.js server-side code: var app = require('http').createServer(handler) , io =
I have another simple question about Node. I'm trying to make a simple http
I'm trying to implement an http long polling server in Node.js, and have no
I am trying to install node http-proxy with the following: npm install http-proxy But

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.