Jenkins reverse proxy on single domain with multiple apps

Aziz Rozyev arozyev at nginx.com
Sun Feb 25 13:11:40 UTC 2018


Hi,

compare the output of 

  curl -ivvv http://jenkins:8080
  curl -ivvv http://localhost/jenkins

then

  curl -iLvvv http://jenkins:8080
  curl -iLvvv http://localhost/jenkins

pay attention on the cookie headers.

java based applications usually may set session cookies and you should
handle them accordingly.

and it’s not clear (at least for me) why you’ve mentioned localhost/app1|2,
is that app1/app2 are different jenkins applications servers?


br,
Aziz.





> On 25 Feb 2018, at 11:08, kefiras at gmail.com <nginx-forum at forum.nginx.org> wrote:
> 
> Hello,
> 
> I am trying to setup a reverse proxy on a single domain to host multiple
> apps separated by URI, for example:
> http://localhost/app1
> http://localhost/app2
> etc.
> 
> Right know having problems with reverse proxy jenkins which sends HTML page
> in HTTP reply with relative paths eg. /static/abc/css/common.css
> 
> So far I have rewritten the content to the login screen as per below but I
> want to know if there is any other way to rewrite this automatically:
> 
> location /jenkins {
>        proxy_pass    http://jenkins:8080/;
>        sub_filter 'url=/login?from=%2F' 'url=/jenkins/login?from=%2F';
>        sub_filter "('/login?from=%2F')" "('/jenkins/login?from=%2F')";
>        sub_filter_once off;
> 
>    }
> 
> 
> Once I hit http://localhost/jenkins I am getting whole bunch of 404 because
> of relative links as per the HTML response below
> 
> 
>  <!DOCTYPE html><html><head resURL="/static/a4190cd9" data-rooturl=""
> data-resurl="/static/a4190cd9">
> 
> 
>    <title>Jenkins [Jenkins]</title><link rel="stylesheet"
> href="/static/a4190cd9/css/layout-common.css" type="text/css" /><link
> rel="stylesheet" href="/static/a4190cd9/css/style.css" type="text/css"
> /><link rel="stylesheet" href="/static/a4190cd9/css/color.css"
> type="text/css" /><link rel="stylesheet"
> href="/static/a4190cd9/css/responsive-grid.css" type="text/css" /><link
> rel="shortcut icon" href="/static/a4190cd9/favicon.ico"
> type="image/vnd.microsoft.icon" /><link color="black" rel="mask-icon"
> href="/images/mask-icon.svg" /><script>var isRunAsTest=false; var
> rootURL=""; var resURL="/static/a4190cd9";</script><script
> src="/static/a4190cd9/scripts/prototype.js"
> type="text/javascript"></script><script
> src="/static/a4190cd9/scripts/behavior.js"
> type="text/javascript"></script><script
> src='/adjuncts/a4190cd9/org/kohsuke/stapler/bind.js'
> type='text/javascript'></script><script
> src="/static/a4190cd9/scripts/yui/yahoo/yahoo-min.js"></script><script
> src="/static/a4190cd9/scripts/yui/dom/dom-min.js"></script><script
> src="/static/a4190cd9/scripts/yui/event/event-min.js"></script><script
> src="/static/a4190cd9/scripts/yui/animation/animation-min.js"></script><script
> src="/static/a4190cd9/scripts/yui/dragdrop/dragdrop-min.js"></script><script
> src="/static/a4190cd9/scripts/yui/container/container-min.js"></script><script
> src="/static/a4190cd9/scripts/yui/connection/connection-min.js"></script><script
> src="/static/a4190cd9/scripts/yui/datasource/datasource-min.js"></script><script
> src="/static/a4190cd9/scripts/yui/autocomplete/autocomplete-min.js"></script><script
> src="/static/a4190cd9/scripts/yui/menu/menu-min.js"></script><script
> src="/static/a4190cd9/scripts/yui/element/element-min.js"></script><script
> src="/static/a4190cd9/scripts/yui/button/button-min.js"></script><script
> src="/static/a4190cd9/scripts/yui/storage/storage-min.js"></script><script
> src="/static/a4190cd9/scripts/hudson-behavior.js"
> type="text/javascript"></script><script
> src="/static/a4190cd9/scripts/sortable.js"
> type="text/javascript"></script><script>crumb.init("Jenkins-Crumb",
> "3842e2c3b39902ce834febe3772fe35c");</script><link rel="stylesheet"
> href="/static/a4190cd9/scripts/yui/container/assets/container.css"
> type="text/css" /><link rel="stylesheet"
> href="/static/a4190cd9/scripts/yui/assets/skins/sam/skin.css"
> type="text/css" /><link rel="stylesheet"
> href="/static/a4190cd9/scripts/yui/container/assets/skins/sam/container.css"
> type="text/css" /><link rel="stylesheet"
> href="/static/a4190cd9/scripts/yui/button/assets/skins/sam/button.css"
> type="text/css" /><link rel="stylesheet"
> href="/static/a4190cd9/scripts/yui/menu/assets/skins/sam/menu.css"
> type="text/css" /><meta name="ROBOTS" content="INDEX,NOFOLLOW" /><meta
> name="viewport" content="width=device-width, initial-scale=1" /><script
> src="/static/a4190cd9/jsbundles/page-init.js"
> type="text/javascript"></script></head><body
> data-model-type="jenkins.install.SetupWizard" id="jenkins"
> class="yui-skin-sam full-screen jenkins-2.60.3" data-version="2.60.3"><div
> id="page-body" class="clear"><div id="main-panel"><a
> name="skip2content"></a><script
> src="/static/a4190cd9/jsbundles/pluginSetupWizard.js"
> type="text/javascript"></script><link rel="stylesheet"
> href="/static/a4190cd9/jsbundles/pluginSetupWizard.css" type="text/css"
> /><form method="POST" action="j_acegi_security_check"><input name="from"
> type="hidden" value="/" /><div class="plugin-setup-wizard bootstrap-3"><div
> class="modal fade in" style="display: block;"><div class="modal-dialog"><div
> class="modal-content"><div class="modal-header"><h4
> class="modal-title">Getting Started</h4></div><div class="modal-body"><i
> class="water-mark icon-service"></i><div class="jumbotron welcome-panel
> offline"><h1>Unlock Jenkins</h1><p>To ensure Jenkins is securely set up by
> the administrator, a password has been written to the log (<small><a
> href="https://jenkins.io/redirect/find-jenkins-logs" target="_blank">not
> sure where to find it?</a></small>) and this file on the server:
> <p><small><code>/var/jenkins_home/secrets/initialAdminPassword</code></small></p></p><p>Please
> copy the password from either location and paste it below.</p><div
> class="form-group "><label class="control-label"
> for="security-token">Administrator password</label><input name="j_username"
> type="hidden" value="admin" /><input id="security-token"
> class="form-control" type="password" name="j_password"
> /></div></div></div><div class="modal-footer"><input type="submit"
> class="btn btn-primary set-security-key" value="Continue"
> /></div></div></div></div></div></form></div></div></body></html>
> 
> Posted at Nginx Forum: https://forum.nginx.org/read.php?2,278748,278748#msg-278748
> 
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx



More information about the nginx mailing list