node.js - How to configure reverse proxy rules for gitlab on nodejs express -


i'm developing nodejs application serve private gitlab server. got working apache, wan't replace apache nodejs application. got working.

website working properly, can see projects etc.

when try clone repository this

git clone http://example.com:3000/apps/test.git 

it clone empty repository, , gives this

cloning 'test'... warning: appear have cloned empty repository. checking connectivity... done. 

repository not empty. work's when clone using apache

app.js

let express = require('express'),     app = express(),      port = process.env.port||3000      httpproxy = require('http-proxy'),     path = require('path'),     httpproxyrules = require('http-proxy-rules'),     proxy = httpproxy.createproxyserver()   app.use((req, res, next) => {     let targeturi= `http://localhost:8181${req.url}`     let targeturi2= `http://localhost:8080${req.url}`      let proxyrules = new httpproxyrules({         rules: {             '/[\\w\.-]+/[\\w\.-]+/repository/archive.*': targeturi,             '/api/v3/projects/.*/repository/archive.*': targeturi,             '/[\\w\.-]+/[\\w\.-]+/(info/refs|git-upload-pack|git-receive-pack)$': targeturi,             '/uploads': targeturi2         },         default: 'http://localhost:8080'          let proxy = new httpproxy.createproxy()         let target = proxyrules.match(req)          if(target)             return proxy.web(req, res { target }      }) }) console.log(`listening port ${port}`) app.listen(port) 

package.json

"dependencies": {     "express": "^4.13.4",     "http-proxy": "^1.13.2",     "http-proxy-rules": "^1.0.1" } 

i found working resolution rules.

let targeturi = `http://localhost:8181${req.url}`  let proxyrules = new httpproxyrules({     rules: {         '/api/v3/.*': targeturi,         '/uploads': targeturi     },     default: 'http://localhost:8181' }) 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -