Created
August 28, 2013 06:37
-
-
Save fkei/6362774 to your computer and use it in GitHub Desktop.
リクエストを別のHTTPサーバーに問い合わせるプログラム
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* web server: express | |
* | |
* リクエストを別のHTTPサーバーに問い合わせるプログラム | |
* - リクエストヘッダー等はコピーしていないです。 | |
*/ | |
var fs = require('fs'); | |
var path = require('path'); | |
var zlib = require('zlib'); | |
var querystring = require('querystring'); | |
var request = require('request'); | |
var _ = require('underscore'); | |
var configure = { | |
proxy: { | |
protocol: 'http', // HTTP Protocol | |
domain: 'example.com' // アクセス先ドメイン | |
} | |
}; | |
exports.index = function (req, res){ | |
var protocol = config.proxy.protocol; | |
var domain = config.proxy.domain; | |
var url = protocol + '://' + domain + req.url; | |
request(url).pipe(res); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment