Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. var http = require('http'),
  2. fs = require('fs'),
  3. connect = require('connect'),
  4. httpProxy = require('http-proxy'),
  5.  
  6. proxy = httpProxy.createProxyServer({});
  7.  
  8. proxy.on('proxyReq', function (proxyReq, req, res, options) {
  9. if (req.headers['content-type']==='text/xml') {
  10. // send it to target and also forward to another server
  11. }
  12. });
  13.  
  14.  
  15. var app = connect()
  16. .use(function (req, res) {
  17. proxy.web(req, res,
  18. {
  19. target: {
  20. port: 8081,
  21. host: 'localhost'
  22. }
  23. })
  24. });
  25.  
  26. http.createServer(app).listen(8080, function () {
  27. console.log('proxy listen 8080');
  28. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement