node-http-proxy | A full-featured http proxy for node.js | Proxy library
kandi X-RAY | node-http-proxy Summary
kandi X-RAY | node-http-proxy Summary
A full-featured http proxy for node.js
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Create the right proxy proxy functions
- Run set changes on set server
- Creates a proxy server object
- Runs the tests on the specified port .
- The request handler .
- Constructor for Proxy server .
- Create an error handler .
- send the server
- handle incoming messages
- Call this function .
node-http-proxy Key Features
node-http-proxy Examples and Code Snippets
{
"/api/*": {
"target": "http://localhost:8080",
"secure": "false",
"logLevel": "debug",
"changeOrigin": true
}
building modules 3/3 modules 0 active[HPM] Proxy created: /api ->
http://localhost
set HTTPS_PROXY=http://domain%5Cusername:password@proxy:80
set HTTP_PROXY=http://domain%5Cusername:password@proxy:80
npm config set proxy http://domain%5Cusername:password@proxy:80
npm config set http-proxy http://
npm config delete http-proxy
npm config delete https-proxy
npm config rm proxy
npm config rm https-proxy
set HTTP_PROXY=null
set HTTPS_PROXY=null
; userconfig C:\Users\taras\.npmrc
http-proxy = "http://username:password@ip:port"
https-proxy = "http://username:password@ip/:port"
registry = "http://registry.npmjs.org/"
strict-ssl = false
npm config set http-proxy http://your_proxy_ip:port
npm config set https-proxy http://your_proxy_ip:port
npm config set http-proxy http://:@[proxy-server-host-name]:[Port]
npm config set https-proxy https://:@[proxy-server-host-name]:[Port]
npm config set http-proxy http://testuser:testpassword@proxy.testserver.com:90
#nmap -sS -O XX.XXX.XX.XXX
Starting Nmap 7.01 ( https://nmap.org ) at 2019-05-13 21:13 UTC
Nmap scan report for myservice (XX.XXX.XX.XXX)
Host is up (0.000024s latency).
Not shown: 998 closed ports
PORT STATE SERVICE
22/tcp open ss
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: oauth2-proxy
namespace: default
annotations:
kubernetes.io/ingress.class: "nginx"
spec:
rules:
- host: example.com
http:
paths:
- backend:
npm config delete proxy
npm config delete http-proxy
npm config delete https-proxy
logLevel: 'debug'
[HPM] Subscribed to http-proxy events: [ 'error', 'close' ]
[HPM] GET /static/api/returnReasons/returnReasons.php -> http://vuetools:8888
Community Discussions
Trending Discussions on node-http-proxy
QUESTION
I'm investigating the use of http-proxy-middleware / node-http-proxy as a reverse proxy. Does anyone know if this is really possible?
I've already setup http-proxy-middleware so that I can proxy a request through it (the results are displayed in an iframe), and I'm also able to modify the request headers and html results. Specifically, I'm setting the host/origin headers and rewriting the result to change embedded links so that they go through the proxy as well.
But, some links are generated by js, and rewriting javascript responses seems to be very difficult to do correctly.
Is there a way to do this without rewriting links? I.e., is there any method to configure the iframe to automatically send all requests through the proxy?
Or maybe this is not really possible, and I'd need to use a full proxy like Squid?
Thanks!
...ANSWER
Answered 2022-Feb-24 at 20:52Use of a reverse proxy should be 100% transparent to clients and your application code, with zero code changes. So perhaps it is a design problem where I can clarify requirements for you.
URL DESIGN
As an API example, I might design URLs as follows for an API:
- Public URL: https://api.mycompany.com/products
- Internal URL: https://productservice.internal.com:3000
Note that the public URL of the API is actually that of a route within the reverse proxy.
An internet client would only ever use the public URL. If the internal API ever returns URLs to internet clients, it needs to be configured to use the public URL.
REVERSE PROXIES
The most mature options are probably the nginx based ones, which provide both declarative routing and also the ability to write any logic you like via plugins. There are plenty of examples in Curity guides, which may make you aware of some use cases
A mainstream option is to use the proxy-pass
directive to route to an internal URL. The same pattern should work for the node RP you mention, though for simple tasks no custom logic should be needed.
Header configuration is a common thing to do in the RP, eg to ensure that the component receives the original client's IP address, rather than that of the RP, but that is often optional.
MISBEHAVING BACKEND COMPONENT
Perhaps this is the root of the problem - if a website returns the internal URL, eg in redirects or image URLs, then it is wrong. Many tech stacks will have a property such as BaseUrl
that fixes this.
QUESTION
My current setup for the project I'm working on is:
- Next.js
- Wordpress backend with GraphQL plugin enabled
- They live on two different servers
I would like to be able to make a request from a Next.js page that proxy via an api-route to the Wordpress backend. I want the GraphQL query to be passed along and I would like to be able to modify the request (for example add header, set a cookie etc) before it reaches the Wordpress backend.
I first tried to achieve this using this module: https://github.com/http-party/node-http-proxy and using the .web()
request. It almost worked except I got back a response from Wordpress that I wasn't able to decode (tried with Buffer etc, but no success).
So my current way to do this is to make an axios
-request from my api route and pass along the req.body
in that request, and that setup works.
However, is this way to proxy OK or should I try to make it work with node-http-proxy
? Don't know about what possible benefits there are.
Thank you
...ANSWER
Answered 2021-Aug-31 at 08:47if you use Axios
you will make an extra request when you retrieve data from the source. This will decrease performance. On the other side if you use proxy you will forward the incoming request and this way you will have improved performance.
QUESTION
I am using the coinbase-pro library to make post request to the coinbase sandbox api through a form on localhost. I am trying to use node-http-proxy to get around a CORS error with no success. Ive been banging my head against the wall for a while on this, any help would be appreciated.
...ANSWER
Answered 2020-Dec-10 at 13:46The answer is here:
I think modifying the proxy response header is not covered in the current doc.
QUESTION
Problem Introduction Language version: Python 3.8
Operating System: Windows 10
Other relevant software: Jupyter notebook and html-requests
Context: I have been following along with this tutorial to scrape stackoverflow for questions. My goal is to extract the answers (from the url of the question) and who answered it. However, I am having difficulty determining what classes/id's to search for in the html of a question
Things I have tried: I have attempted searching under ('.container') for things like ('.post-layout'), '.mb0', '#answers', and'#answers-headers' with marginal, cluttered, success.
An excerpt from the code I am using to parse the pages(not the questions) here is the github link:
...ANSWER
Answered 2020-Oct-13 at 21:24You should look for .answercell
class
QUESTION
My question is: is http-proxy, reverse-proxy.js, or any other library(with exception of a web-server like nginx) capable of routing all requests that comes to the port 80 to another services based on the url?
If a request comes at the port 80 with that url localhost:80/route1
I want to redirect it to the service at localhost:3001
If a request comes at the port 80 with that url localhost:80/another-route
I want to redirect it to the service at localhost:3002
. And so on..
To summarize it: I want to expose 1 port(80), and then route the request to other services based on the URL pattern from the request. So far I tried this approach below using reverse-proxy.js but it only works if the port changes
...ANSWER
Answered 2020-Sep-08 at 21:16Yes of course you can. It's a very common requirement. In Node you can do it natively using streams. Here's a full working example using only the standard Node http library.
QUESTION
I need a way to remove the X-Frame-Options
header from the responses from a few websites before those responses reach my browser.
I am doing this so that I can properly render my custom kiosk webpage, which has iframe
s that point to websites that don't want to show up in frames.
I have tried setting up a proxy using squid
and configuring its reply_header_access
option to deny
X-Frame-Options
headers as the server receives them, but that is for some reason not working as anticipated. I have verified that I am indeed going through the Squid proxy, and I have verified that the X-Frame-Options
header persists despite my squid.conf
file containing the following:
ANSWER
Answered 2020-May-28 at 01:29I used a proxy, specifically mitmproxy with the following script:
QUESTION
I need help creating a proxy server using node js to use with firefox.
the end goal is to create a proxy server that will tunnel the traffic through another proxy server (HTTP/SOCKS) and return the response back to firefox. like this
I wanna keep the original response received from the proxy server and also wanna support https websites as well.
Here is the code I came up with.
...ANSWER
Answered 2020-May-02 at 10:59You have to use some middleware like http-proxy module.
Documentation here: https://www.npmjs.com/package/http-proxy
Install it using npm install node-http-proxy
This might help too: How to create a simple http proxy in node.js?
QUESTION
I have an http-proxy to proxy any website and inject some custom JS file before to serve the HTML back to the client. Whenever I try to access the proxied website, it will hang up or the browser seems to load indeterminately. But when I check the HTML source, I successfully managed to inject my custom JavaScript file. Here is the code:
...ANSWER
Answered 2020-Mar-21 at 07:04Your code looked fine so I was curious and tried it.
Although you do log a few errors, you don't handle several cases:
- The server returns a body with no response (
cheerio
will generate an empty HTML body when this happens) - The server returns a response that is not gzipped (your code will silently discard the response)
I made a few modifications to your code.
Change initial optionsCommunity Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install node-http-proxy
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page