2016-05-09 2 views
0

私は現在、プライベートgitlabサーバを提供するnodejsアプリケーションを開発中です。私はApacheで動作させましたが、ApacheをNodejsアプリケーションに置き換えることはできません。私はそれがほとんど働いている。nodejsでgitlabのリバースプロキシルールを設定する方法

ウェブサイトが正常に動作している、私は私のプロジェクトを見ることができるなど

私はこの

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

のようにリポジトリのクローンを作成しようとするとそれは空のリポジトリのクローンを作成し、この

Cloning into 'test'... 
warning: You appear to have cloned an empty repository. 
Checking connectivity... done. 
を与えます

リポジトリが空ではありません。それは私がそれは、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" 
} 

答えて

0

を使用してクローンを作成するとき、私はルールの作業解像度を見つけたのが仕事します。

let targetUri = `http://localhost:8181${req.url}` 

let proxyRules = new HttpProxyRules({ 
    rules: { 
     '/api/v3/.*': targetUri, 
     '/uploads': targetUri 
    }, 
    default: 'http://localhost:8181' 
}) 
関連する問題