Skip to content
This repository has been archived by the owner on Feb 14, 2020. It is now read-only.

Commit

Permalink
Always proxy to IPv4
Browse files Browse the repository at this point in the history
Trying to proxy to IPv6 first resulted in POST bodies being sent to
IPv6, then IPv4 not getting the body when IPv6 failed.
  • Loading branch information
causal-agent committed Jan 27, 2014
1 parent f5b3e04 commit 844b865
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions pult-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,9 @@ function httpRequest(req, res) {
resJSON(res, 200, ports);
}
} else if (port) {
proxy.web(req, res, { target: 'http://[::1]:' + port },
function proxyWebError6(err) {
proxy.web(req, res, { target: 'http://127.0.0.1:' + port },
function proxyWebError4(err) {
resJSON(res, 502, err);
});
proxy.web(req, res, { target: 'http://127.0.0.1:' + port },
function proxyWebError4(err) {
resJSON(res, 502, err);
});
} else {
resJSON(res, 502, { host: host });
Expand All @@ -144,12 +141,9 @@ function httpRequest(req, res) {
function httpUpgrade(req, socket, head) {
var port = getPort(req.headers.host);
if (port) {
proxy.ws(req, socket, head, { target: 'ws://[::1]:' + port },
function proxyWsError6(err) {
proxy.ws(req, socket, head, { target: 'ws://127.0.0.1:' + port },
function proxyWsError4(err) {
resJSON(res, 502, err);
});
proxy.ws(req, socket, head, { target: 'ws://127.0.0.1:' + port },
function proxyWsError4(err) {
resJSON(res, 502, err);
});
} else {
resJSON(res, 502, { host: req.headers.host });
Expand Down

0 comments on commit 844b865

Please sign in to comment.