另一台服务器上托管的gitlab的Apache反向代理
在过去的几个月里,我一直在尝试使用Apache作为反向代理,但我无法以我想要的方式配置它 网络配置 在我的本地网络中,所有传入的HTTP请求都由我的防火墙路由到Apache服务器(在Debian上运行)。此Apache服务器承载3个不同的Web服务 第四个web服务,Gitlab,托管在第二台服务器(Ubuntu)上,并在docker中运行。我的内部DNS将Gitlab引用为另一台服务器上托管的gitlab的Apache反向代理,apache,proxy,gitlab,reverse-proxy,Apache,Proxy,Gitlab,Reverse Proxy,在过去的几个月里,我一直在尝试使用Apache作为反向代理,但我无法以我想要的方式配置它 网络配置 在我的本地网络中,所有传入的HTTP请求都由我的防火墙路由到Apache服务器(在Debian上运行)。此Apache服务器承载3个不同的Web服务 第四个web服务,Gitlab,托管在第二台服务器(Ubuntu)上,并在docker中运行。我的内部DNS将Gitlab引用为Gitlab/。因此,我可以从URLhttp://gitlab/ 期望的Apache行为 我想通过在浏览器中键入以下内容,
Gitlab/
。因此,我可以从URLhttp://gitlab/
期望的Apache行为
我想通过在浏览器中键入以下内容,从Internet访问这4种不同的web服务:
http://ip_address/web_service_1/
http://ip_address/web_service_2/
http://ip_address/web_service_3/
http://ip_address/gitlab/
网络服务1到网络服务3运行良好。但我不知道如何将Apache配置为Gitlab的代理
从互联网上,对Gitlab的请求应该通过防火墙,路由到运行Apache的Debian服务器,最后路由到运行Gitlab的Ubuntu服务器
不幸的是,当我向http://ip_address/gitlab
,我收到http://ip_address/users/sign_in
而不是http://ip_address/gitlab/users/sign_in
和Apache无法将下一个请求路由到Gitlab be,因为/Gitlab/
部分消失
Apache配置
为了得到上面解释的结果,我在Debian服务器上创建了一个名为/etc/apache2/sites available/proxy.conf
的文件,其中包含:
<VirtualHost *:80>
ServerName myProxy
RewriteEngine On
RewriteRule ^/web_service_1(.*) http://debian_server/web_service_1/$1
RewriteRule ^/web_service_2(.*) http://debian_server/web_service_2/$1
RewriteRule ^/web_service_3(.*) http://debian_server/web_service_3/$1
ProxyPass /gitlab http://gitlab/
ProxyPassReverse /gitlab http://gitlab/
</VirtualHost>
使用此解决方案,我几乎可以进入登录页面,但是缺少一些元素,我无法登录。也许我忘记了代理配置中的一些选项
有人知道如何改进此解决方案并使其生效吗
非常感谢你的帮助
<VirtualHost *:80>
ServerName myProxy
ServerAlias myProxy
DocumentRoot /var/www/html
RewriteEngine On
LogLevel error trace6
RewriteRule ^/web_service_1(.*) http://127.0.2.1/web_service_1/$1 [P]
RewriteRule ^/web_service_2(.*) http://127.0.2.2/web_service_2/$1 [P]
RewriteRule ^/web_service_3(.*) http://127.0.2.3/web_service_3/$1 [P]
ProxyRequests Off
ProxyPass /gitlab/ http://gitlab/
ProxyHTMLURLMap http://gitlab /gitlab
<Location /gitlab/>
ProxyPassReverse /
ProxyHTMLEnable On
ProxyHTMLURLMap / /gitlab/
RequestHeader unset Accept-Encoding
</Location>
</VirtualHost>