Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proxy-by-url
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
proxy-by-url
Commits
810b69a3
Commit
810b69a3
authored
Jul 30, 2011
by
Dominic Tarr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[fix] fallback to next middleware if there is no rule.
[doc] add readme
parent
d5b34001
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
index.js
index.js
+2
-1
readme.markdown
readme.markdown
+13
-0
No files found.
index.js
View file @
810b69a3
...
@@ -47,8 +47,9 @@ module.exports = function (urls) {
...
@@ -47,8 +47,9 @@ module.exports = function (urls) {
// If routing to a server on another domain, the hostname in the request must be changed.
// If routing to a server on another domain, the hostname in the request must be changed.
req
.
headers
.
host
=
m
.
host
;
req
.
headers
.
host
=
m
.
host
;
// Once any changes are taken care of, this line makes the magic happen.
// Once any changes are taken care of, this line makes the magic happen.
proxy
.
proxyRequest
(
req
,
res
,
m
.
dest
);
return
proxy
.
proxyRequest
(
req
,
res
,
m
.
dest
);
}
}
}
}
next
()
//did not have a rule for this request. fall back to next middleware.
}
}
}
}
readme.markdown
View file @
810b69a3
#proxy by url
this is a simple example of a node-http-middleware that will proxy based on the incoming url.
say you want to proxy every request thing under /database to localhost:5984 (couchbd)
(and remove the /database prefix)
this is how:
require('http-proxy').createServer(
require('proxy-by-url')({
'/database': { port: 5984, host: 'localhost' },
})
).listen(8000)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment