0

I have a VPS that I use to run a personal Gerrit and Jenkins server. After a year of neglect I finally decided to get it working again. Previously I have used gerrit.server.com and jenkins.server.com, but this caused a lot of issues with https certification, so I decided to just go over to subdirectory(?), e.g server.com/jenkins. I managed to get the Gerrit server updated and working as server.com/gerrit, but the Jenkins instance just wont work. I've tried pretty much all of yesterday and this morning but with no luck.

The issue seems to be some kinds of problem with the handover between the revese proxy and Jenkins, because when i write server.com/jenkins is gets redirected(?) to server.com/login?from=%2Fjenkins%2F. I think that Jenkins somehow gets called, and then thinks that the /jenkins is an argument for it, but I'm not that good with how apache works.

If I try to directly access the jenkins server by going to server.com:8081 it works as expected.

My apache config is as follows:

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        ServerName www.<serverURL>.com

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf

        ProxyPass "/jenkins" "http://localhost:8081/jenkins/" nocanon
        ProxyPassReverse "/jenkins" "http://localhost:8081/jenkins/"

        ProxyRequests     Off
        ProxyPreserveHost On
        AllowEncodedSlashes On

        ProxyPass "/gerrit" http://localhost:8080/gerrit nocanon
        ProxyPassReverse "/gerrit" "http://localhost:8080/gerrit"

        <Proxy *>
          Require all granted
        </Proxy>

</VirtualHost>

I hope this is the correct community to post this question in. I'm all out of ideas what to do or what to search for to solve this. Any ideas are welcomed.

Thanks in advance

/Jaxc

0

You will need to update your $PREFIX variable for the new URI. This is in your jenkins.xml configuration file or add it as a startup argument --prefix=/jenkins on the command line.

Here is the answer previously.

https://stackoverflow.com/a/9119377/13483200

| improve this answer | |
New contributor
emulover1963 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • Thanks for your answer!When i do this, and restart Jenkins, I'm meet with a service unavailable and can no longer reach the site at server.com:8081 – Jaxc May 22 at 13:39
  • Can you post any Apache access or error logs? – emulover1963 May 22 at 14:04
  • Here is the error log: [Fri May 22 17:02:02.714968 2020] [proxy:error] [pid 28499] (111)Connection refused: AH00957: HTTP: attempt to connect to 127.0.0.1:8081 (localhost) failed [Fri May 22 17:02:02.716983 2020] [proxy_http:error] [pid 28499] [client <My IP>:39864] AH01114: HTTP: failed to make connection to backend: localhost and access log:[22/May/2020:17:02:02 +0200] "GET /jenkins HTTP/1.1" 503 571 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36" – Jaxc May 22 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.