Giter Site home page Giter Site logo

Comments (4)

GuyPaddock avatar GuyPaddock commented on July 28, 2024

Hi Jordan,

First, it looks like the Harmon-Binary package pull request was accepted upstream in harmon itself, so you might be better off using harmon directly. I haven't tested it myself just yet, but once I do, I'll be dropping this separate project from Github.

Secondly, when you say the the requests "mess up", what do you mean? Are multiple requests running over each other, is the output garbled, or are you getting an error message?

One other important thing to pay attention to is how you end up replacing or removing content in the stream. I tend to use the "through" module with NodeJS for all of my edits or content removals, like so:

func: function(htmlNode, req, res) {
// "outer: true" => modify the matching element.
var stream = htmlNode.createStream({outer: true});

stream.pipe(through(function (buf) {
// Pipe nothing through to the document; just eliminate the element.
})).pipe(stream);
}

The above would completely remove the target element from the output.

Thanks!

Sincerely,

Guy A. Paddock

Chief Executive Officer
RedBottle Design

(585) 563-4012
----- Original Message -----

From: "Jordan Coeyman" [email protected]
To: "GuyPaddock/harmon-binary" [email protected]
Sent: Thursday, December 18, 2014 10:35:16 AM
Subject: [harmon-binary] Whats the issue stopping me from using this on other websites? (#1)

Love the package thanks for the work :)
I'm trying to get https://github.com/GuyPaddock/harmon-binary/blob/master/examples/doge.js to work, but simply with another website. The example runs great, but once I switch out nodejs.org for anything else (ie: google.com ), the requests mess up.
Any tips? (I'm trying to run this from a wildcard - *.example.com)

Reply to this email directly or view it on GitHub .

from harmon-binary.

acoyfellow avatar acoyfellow commented on July 28, 2024

Guy, thanks for the super quick response..

I'm not even trying to modify anything (yet) on the server I am attempting to proxy to. I just wanted to get the proxy up and running, then I was going to do the modifications I needed.

I can't seem to understand what exactly is going on.. No errors in the server console.

I get a different browser error based on the server I am trying to proxy to upon request.

For example I see an nginx 502 bad gateway on my own site, when I point the proxy to Google I see a custom Google "Not Found" error, and when I point it to clickhole.com (random site, satire news) it spits a custom 503 service unavail. The example of nodejs.org works perfectly though.

from harmon-binary.

GuyPaddock avatar GuyPaddock commented on July 28, 2024

Hmm, it sounds like the request headers aren't being passed through properly. You may need to rewrite the "host" header that is being passed through the proxy to make sure that the site you're proxying knows which site to serve-up.

Typically, the browser sends the site a request header that says "Ok, I'm vising google.com, so send me the content for that site" and then the server knows which site its serving up (in case multiple sites are hosted on the same IP / machine).

In another project, we use this snippet of code to create the proxy:

var proxy = httpProxy.createProxyServer({
target: targetProto + '://' + targetTld,
secure: false,
headers: {
// Force the host to match the target.
host: targetTld,
}
});

Where httpProxy is the http-proxy module (created via require() ), targetProto is either "http" or "https", targetTld is the target domain name (like "google.com" or "facebook.com", etc).

----- Original Message -----

From: "Jordan Coeyman" [email protected]
To: "GuyPaddock/harmon-binary" [email protected]
Cc: "Guy Paddock" [email protected]
Sent: Thursday, December 18, 2014 10:49:34 AM
Subject: Re: [harmon-binary] Whats the issue stopping me from using this on other websites? (#1)

Guy, thanks for the super quick response..
I'm not even trying to modify anything (yet) on the server I am attempting to proxy to. I just wanted to get the proxy up and running, then I was going to do the modifications I needed.
I can't seem to understand what exactly is going on.. No errors in the server console.
I get a different error based on the server I am trying to proxy to.
For example I see an nginx 502 bad gateway, when I point the proxy to Google I see a custom Google "Not Found" error, and when I point it to clickhole.com (random site, satire news) it spits a custom 503 service unavail. The example of nodejs.org works perfectly though.

Reply to this email directly or view it on GitHub .

from harmon-binary.

acoyfellow avatar acoyfellow commented on July 28, 2024

Guy you rock, thank you for your help. Got it working with your help 👍

from harmon-binary.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.