File tree 1 file changed +33
-0
lines changed
1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ var http = require ( 'http' ) ,
2
+ httpProxy = require ( '../lib/http-proxy' ) ;
3
+
4
+ //
5
+ // Target Http Server
6
+ //
7
+ http . createServer ( function ( req , res ) {
8
+ res . writeHead ( 200 , { 'Content-Type' : 'text/plain' } ) ;
9
+ res . write ( 'request successfully proxied to: ' + req . url + '\n' + JSON . stringify ( req . headers , true , 2 ) ) ;
10
+ res . end ( ) ;
11
+ } ) . listen ( 9000 ) ;
12
+ console . log ( "Web server listening on port 9000" ) ;
13
+
14
+ //
15
+ // Target Http Forwarding Server
16
+ //
17
+ http . createServer ( function ( req , res ) {
18
+ console . log ( 'Receiving forward for: ' + req . url ) ;
19
+ res . writeHead ( 200 , { 'Content-Type' : 'text/plain' } ) ;
20
+ res . write ( 'request successfully forwarded to: ' + req . url + '\n' + JSON . stringify ( req . headers , true , 2 ) ) ;
21
+ res . end ( ) ;
22
+ } ) . listen ( 9001 ) ;
23
+
24
+ //
25
+ // Basic Http Proxy Server
26
+ // Forward example: send requests without care about response
27
+ //
28
+ httpProxy . createServer ( {
29
+ target : 'http://localhost:9000' ,
30
+ forward : 'http://localhost:9001'
31
+ } ) . listen ( 8000 )
32
+ console . log ( "Proxy server listening on port 8000" ) ;
33
+
You can’t perform that action at this time.
0 commit comments