Last active
October 11, 2015 10:17
-
-
Save charyorde/64230d4849e5dec4e1f9 to your computer and use it in GitHub Desktop.
Testing reverse proxy app on CF
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
var express = require('express') | |
var app = express() | |
var cors = require('cors') | |
// start http server | |
var server = app.listen(process.env.VCAP_APP_PORT, function () { | |
var host = server.address().address | |
var port = server.address().port | |
console.log('Proxying Yookore at http://%s:%s', host, port) | |
}) | |
// Using strong-gateway's http-proxy wrapper | |
// for node-http-proxy | |
// see https://github.com/strongloop/strong-gateway/blob/master/server/middleware/proxy/index.js | |
var proxy = require('./strong-gateway/server/middleware/proxy/index') | |
app.use(cors()); | |
app.use(proxy({ | |
"rules": [ | |
"^/auth/v1/(.*)$ http://uas.apps.cf.net/v1/$1 [P]" | |
})); | |
// App at http://uas.apps.cf.net/v1 | |
var router = app.Router(); | |
app.use('/v1', router); | |
router.get('/', function(req, res) { | |
return res.status(200).send("Welcome to UAS") | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment