0

I have a blog here.

And this is what I do:

var httpProxy = require('http-proxy'); 
var apiProxy = httpProxy.createProxyServer();

app.get("/blog/", function(req, res){ 
    apiProxy.web(req, res, { target: 'http://69.195.124.88/~crowdfoo/blogbeaconboss/:80' });
});

But it says:

404: File Not Found

When I open: http://www.example.com/blog/ on production or http://localnode.com:3000/blog/ on local machine where localnode is localhost

Would appreciate help in this, Thanks!

Leg0
  • 510
  • 9
  • 21

1 Answers1

0

Edit:

I think part of the problem might be that you're trying to include the path in your proxy URL. I tried this:

var express = require('express');
var app = express();
var httpProxy = require('http-proxy');
var apiProxy = httpProxy.createProxyServer();

app.use('/', function(req, res) {
    apiProxy.web(req, res, {
        target: 'http://69.195.124.88'
    });
});

app.listen(3000, function() {
    console.log('listening');
});

And now I can see your blog at http://localhost:3000/~crowdfoo/blogbeaconboss/ without any issue.

/Edit

You should probably remove the port number :80 at the end of your URL. Try this URL instead:

http://69.195.124.88/~crowdfoo/blogbeaconboss/

Note that the port should be attached to the hostname, not after the path like you had it. If you wanted to specify the port it would look like this:

http://69.195.124.88:80/~crowdfoo/blogbeaconboss/

But this is redundant, the http URL scheme means use port 80 if its left unspecified.

Andrew Lavers
  • 8,023
  • 1
  • 33
  • 50