apache 代理后端服务器的 URI

apache 代理后端服务器的 URI

我想将我的域的一个 URI 代理到特定的后端服务器。

我有一个公共域名external.lan和一个私人域名internal.lan

我想要http://external.lan/gogs得到服务员的服务internal

这是我的 apache 配置块:

ProxyPass "/gogs" "http://internal.lan/gogs"
ProxyPassReverse "/gogs" "http://internal.lan/gogs"

这在日志中返回:

[proxy:debug] [pid 4025] proxy_util.c(2118): AH00924: worker http://backup.localnet.lan shared already initialized

我也尝试过:

ProxyPass "/gogs/(.*)$" "http://internal.lan/$1"
ProxyPassReverse "/gogs" "http://internal.lan/gogs"

这会在外部服务器日志中返回 404 错误。

我也尝试过使用 mod_rewrite:

RewriteEngine On
RewriteRule "^/gogs/(.*)$" "http://internal.lan/$1 [P]
RewriteRule "/gogs/" "http://internal.lan/   [P,L]

没有运气。

如何仅使用一个域名将一些 URI 代理到后端服务器?

编辑:这是我的配置文件:

ServerSignature Off

Alias /glpi/ /var/www/glpi/

#ProxyPass        "/gogs/(.*)$" "http://backup.localnet.lan:6000/$1"
#ProxyPass        "/gogs/"      "http://backup.localnet.lan:6000/"
#ProxyPassReverse "/gogs" "http://backup.localnet.lan:6000/gogs"

ProxyPass "/gogs/" "http://backup.localnet.lan/"
#ProxyPassReverse /gogs/ http://backup.localnet.lan:6000

<VirtualHost web.localnet.lan:80>

   ServerAdmin [email protected]
   ServerName web.localnet.lan
   ServerAlias web

   DocumentRoot /var/www/glpi

   <Directory />
      Options None
      AllowOverride None
   </Directory>

   <Directory /var/www/glpi>
      Options None
      AllowOverride None
   </Directory>

   <Directory /var/www/glpi/files>
      Options None
      AllowOverride None
      Order allow,deny
      deny from all
   </Directory>

#   RewriteEngine On
#   RewriteRule /gogs/(.*) http://backup.localnet.lan/$1 [P,L]
#   RewriteRule /gogs/ http://backup.localnet.lan/ [P,L]
#   RewriteRule "/gogs/"       "http://backup.localnet.lan/   [P,L]
#   ProxyPassReverse "/gogs/" "http://backup.localnet.lan/"
#   #RewriteRule "^/gogs/(.+)" "http://backup.localnet.lan/" [R,L]

   LogLevel  debug rewrite:trace6
   CustomLog ${APACHE_LOG_DIR}/glpi-access.log combined
   ErrorLog  ${APACHE_LOG_DIR}/glpi-error.log

</VirtualHost>

相关内容