создать прокси с http-node-proxy - PullRequest
0 голосов
/ 06 июня 2019

Я пытаюсь разработать локальный прокси-узел для http://proxy_target.com.ar, пока что это то, что я пытался

const http = require('http')
const httpProxy = require('http-proxy')

var proxyOptions = {
  target: 'http://proxy_target.com.ar',
}

var proxy = httpProxy.createProxyServer({})

var server = http.createServer(function (req, res) {
  proxy.web(req, res, proxyOptions);
});

console.log("listening on port 5050")
server.listen(5050);

Теперь, если я добавлю скручивание на сайт proxy_target, я получу:

λ curl -v -i -X GET http://proxy_target.com.ar/EEServices/consulta?wsdl

> GET /EEServices/consulta?wsdl HTTP/1.1
> Host: proxy_target.com.ar
> User-Agent: curl/7.46.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Thu, 06 Jun 2019 00:14:17 -0300
< Server: Mule Core/3.4.0
< Content-Type: text/xml

но если я попытаюсь сделать то же самое с моим прокси:

λ curl -v -i -X GET localhost:5050/EEServices/consulta.wsdl
*   Trying ::1...
* Connected to localhost (::1) port 5050 (#0)
> GET /EEServices/consulta.wsdl HTTP/1.1
> Host: localhost:5050
> User-Agent: curl/7.46.0
> Accept: */*
>
< HTTP/1.1 404 Not Found
HTTP/1.1 404 Not Found
server: Apache-Coyote/1.1
content-type: text/html;charset=utf-8
content-language: en
content-length: 999
date: Thu, 06 Jun 2019 03:11:15 GMT
connection: close

<html><head>
<title>Apache Tomcat/7.0.69 - Error report</title>
</head>
<body>
<h1>HTTP Status 404 - /EEServices/consulta.wsdl</h1>
<u>/EEServices/consulta.wsdl</u>
<u>The requested resource is not available.</u>
<h3>Apache Tomcat/7.0.69</h3>
</body></html>*
Closing connection 0

Я что-то упустил?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...