如何使用非根上下文路径为Apache和Jetty主机设置反向代理

我需要将Apache 2.4设置为Jetty 9后端服务器的反向代理,因此我将拥有公共站点: https://jenkins.mysite.com 它将被代理到内部 http://localhost:8080/jenkins

我尝试了不同的设置,以及:

<IfModule mod_ssl.c>
<VirtualHost *:443>


    ServerName jenkins.mysite.com
    DocumentRoot /home/jenkins/web

    Alias / /home/jenkins/web/
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>


    SSLEngine on
    SSLProxyEngine On

    BrowserMatch    "MSIE [2-6]" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0

    BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

    <Directory "/home/jenkins/web/WEB-INF/">
             AllowOverride None
             Require all denied
    </Directory>

    ProxyRequests Off
    ProxyVia Off

    #Tried On and Off. With ProxyPassReverse and without
    ProxyPreserveHost Off

    #Tried all below settings with no luck
    #AllowEncodedSlashes NoDecode
    #RequestHeader set X-Forwarded-Proto "https" env=HTTPS
    #RequestHeader set X-Forwarded-Port 443

    <Proxy *>
      AddDefaultCharset off
          AllowOverride None
          Require all granted
    </Proxy>

    #Tried below instead of nocanon in ProxyPass
    #RewriteEngine on
    #RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
    #RewriteRule .* http://127.0.0.1:8080/jenkins/%{REQUEST_URI} [NE,P,QSA]

    ProxyPass / http://localhost:8080/jenkins nocanon 
    ProxyPassReverse / http://localhost:8080/jenkins

    #That was useful to remove contextPath from Cookie path
    #ProxyPassReverseCookiePath  "/jenkins"  "/"

    <Location />
       Options FollowSymLinks
       AddDefaultCharset off
       AllowOverride None
       Require all granted
     </Location>

    SSLCertificateFile /etc/letsencrypt/live/jenkins.mysite.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/jenkins.mysite.com/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

对于Jetty,我尝试使用 http转发的模块。不管有没有它都无济于事。

我所能实现的最好的直接链接有效。但是所有引用的url和重定向(例如登录名一)都具有额外的内部contextPath:/ jenkins / *

有什么方法可以设置它吗?尤其是为了避免Jenkins抱怨反向代理已损坏?

如果我将虚拟主机用于带有contextPath = /的码头环境,则可以使其工作。但这需要更改我要避免的/ etc / hosts。

当然,mysite.com是假设名称。我使用了一些真实域名。 谢谢。

ii328397830 回答:如何使用非根上下文路径为Apache和Jetty主机设置反向代理

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3128873.html

大家都在问