Skip to content

Commit

Permalink
proxy to owncloud and phpmyadmin
Browse files Browse the repository at this point in the history
  • Loading branch information
canerbagci committed May 2, 2016
1 parent 290785d commit 451850f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
13 changes: 11 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ function format(obj) {
//console.log(JSON.stringify(data, null, 4));
};
}
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
// app.use(bodyParser.urlencoded({extended: false}));
// app.use(bodyParser.json());

app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
Expand Down Expand Up @@ -104,4 +104,13 @@ app.use(function (err, req, res, next) {
});
});

// var proxy = require('express-http-proxy');
//
// app.use('/proxy', proxy('10.2.30.139:80', {
// forwardPath: function(req, res){
// console.log("forwarding");
// return require('url').parse(req.url).path;
// }
// }));

module.exports = app;
2 changes: 1 addition & 1 deletion bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var http = require('http');
* Get port from environment and store in Express.
*/

var port = normalizePort(process.env.PORT || '3000');
var port = normalizePort(process.env.PORT || '80');
app.set('port', port);

/**
Expand Down
23 changes: 23 additions & 0 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@ var express = require('express');
var router = express.Router();
var mysqlconn = require('../dev/utils/mysqlqueries.js');

var httpProxy = require('http-proxy');
var proxy = httpProxy.createProxyServer();

router.all('/owncloud*', function(req, res, next){
console.log('redirecting ' + req.url);
// req.url = '/owncloud/index.php';
proxy.web(req, res, {target: 'http://10.2.24.26:80/'}, function(e) {
console.log(e);
});
});

router.all('/phpmyadmin*', function(req, res, next){
console.log('redirecting ' + req.url);
proxy.web(req, res, {target: 'http://10.2.24.19:8080/'}, function(e){
console.log(e);
});
});

mysqlconn.connect(function(connection) {
if (!connection) {
console.log("Not connected to mysqldb");
Expand Down Expand Up @@ -45,6 +63,9 @@ router.get('/about', function(req, res, next) {
});
});

var bodyParser = require('body-parser');
router.use(bodyParser.urlencoded({extended: false}));
router.use(bodyParser.json());
//Bibtex Parse routes
router.post('/bibtexParse/registerBibtex', function(req, res) {
for (var i = 0; i < req.body.length; i++) {
Expand Down Expand Up @@ -116,4 +137,6 @@ router.get('/software/mirna/featureList', function(req, res, next) {
});
});



module.exports = router;

0 comments on commit 451850f

Please sign in to comment.