mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 00:03:28 +02:00
* Upgrading STF for security reasons Signed-off-by: Denis barbaron <denis.barbaron@orange.com> * update semaphore files Signed-off-by: Denis barbaron <denis.barbaron@orange.com> * upgrading STF for security reasons v2 Signed-off-by: Denis barbaron <denis.barbaron@orange.com> * update yarn.lock file Signed-off-by: Denis barbaron <denis.barbaron@orange.com> --------- Signed-off-by: Denis barbaron <denis.barbaron@orange.com>
76 lines
1.7 KiB
JavaScript
76 lines
1.7 KiB
JavaScript
/**
|
|
* Copyright © 2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
|
|
**/
|
|
|
|
var http = require('http')
|
|
|
|
var express = require('express')
|
|
var httpProxy = require('http-proxy')
|
|
|
|
var logger = require('../../util/logger')
|
|
|
|
module.exports = function(options) {
|
|
var log = logger.createLogger('poorxy')
|
|
var app = express()
|
|
var server = http.createServer(app)
|
|
var proxy = httpProxy.createProxyServer()
|
|
|
|
proxy.on('error', function(err) {
|
|
log.error('Proxy had an error', err.stack)
|
|
})
|
|
|
|
app.set('strict routing', true)
|
|
app.set('case sensitive routing', true)
|
|
app.set('trust proxy', true)
|
|
|
|
app.disable('x-powered-by')
|
|
|
|
;['/static/auth/*', '/auth/*'].forEach(function(route) {
|
|
app.all(route, function(req, res) {
|
|
proxy.web(req, res, {
|
|
target: options.authUrl
|
|
})
|
|
})
|
|
})
|
|
|
|
;['/s/image/*'].forEach(function(route) {
|
|
app.all(route, function(req, res) {
|
|
proxy.web(req, res, {
|
|
target: options.storagePluginImageUrl
|
|
})
|
|
})
|
|
})
|
|
|
|
;['/s/apk/*'].forEach(function(route) {
|
|
app.all(route, function(req, res) {
|
|
proxy.web(req, res, {
|
|
target: options.storagePluginApkUrl
|
|
})
|
|
})
|
|
})
|
|
|
|
;['/s/*'].forEach(function(route) {
|
|
app.all(route, function(req, res) {
|
|
proxy.web(req, res, {
|
|
target: options.storageUrl
|
|
})
|
|
})
|
|
})
|
|
|
|
;['/api/*'].forEach(function(route) {
|
|
app.all(route, function(req, res) {
|
|
proxy.web(req, res, {
|
|
target: options.apiUrl
|
|
})
|
|
})
|
|
})
|
|
app.use(function(req, res) {
|
|
proxy.web(req, res, {
|
|
target: options.appUrl
|
|
})
|
|
})
|
|
|
|
server.listen(options.port)
|
|
log.info('Listening on port %d', options.port)
|
|
}
|