-1

I have a Jenkins installation which is accessible at localhost:8080 or if accessing externally as website via IPaddress:8080.

I'd like to access the website with something like IPaddress/jenkins instead and have IIS know how to redirect to localhost:8080 internally when accessed like that.

This is my web.config file:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(jenkins.*)" />
                    <action type="Rewrite" url="http://localhost:8080/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Unfortunately, after visiting IPaddress/jenkins I get an error 404.

maar
  • 485
  • 6
  • 20
meds
  • 99
  • 1
  • 3

4 Answers4

0

See here: https://blog.dangl.me/archive/installing-and-configuring-jenkins-on-windows-server-with-iis/ (most relevant for you is the following part of this article: Setting up an IIS Reverse Proxy to Access Jenkins from the Outside)

Ace
  • 478
  • 1
  • 6
0

A few things:

  1. I’m not sure if this applies to the server, but for reverse proxy capability, URL Rewrite needs ARR to be installed.
  2. If this has been completed, make sure reverse proxy is enabled.
  3. If Step 2 has been completed: The rewrite rule currently would rewrite http://ip/jenkins/mypage.jsp to http://ip:8080/jenkins/mypage.jsp. If the intent is to rewrite http://ip/jenkins/mypage.jsp to http://ip:8080/mypage.jsp then I would recommend the match URL to be more like the following instead:

    ^jenkins(\/.*)?$

NOTE If #3 applies, you may need an outbound rule to fix a, img, script elements as well in this scenario.

jayhendren
  • 1,014
  • 5
  • 12
milope
  • 441
  • 2
  • 5
0

Maybe somebody need this answer. It helped me.

Before turning our attention to IIS though, we need to tell Jenkins about our prefix (subdirectory). To do this, open C:\Program Files (x86)\Jenkins\jenkins.xml and add --prefix=/jenkins to the entry.

Esa Jokinen
  • 46,944
  • 3
  • 83
  • 129
Andrey
  • 1
  • 4
    It would be nice if you told where your citation came from. – Esa Jokinen Jul 04 '18 at 15:57
  • 1
    https://medium.com/@notCaseyWebb/deploying-jenkins-to-a-subdirectory-using-iis-on-windows-server-2016-6352589b7a6 seems to be the source. – chicks Jul 04 '18 at 19:53
0

You should take a look at installing the IIS Rewrite Module https://www.iis.net/downloads/microsoft/url-rewrite This is designed to accept inbound URLs that you want to modify before processing. eg, if you need to redirect to a different server, page or port.

Useful to use a UI if you aren't able to modify the web.config (or you don't want to, eg, when its from a 3rd party supplier)