I came here to report this issue and found this one already reported. I have more information to add.
For quite some time I ran haproxy -> jenkins and that worked well. SSL was being terminated at haproxy. I did not get the https URLs being 302'd to http. But I recently added apached in front of the pipeline, e.g. apache -> haproxy -> jenkins. Now SSL is being terminated at apache. And now I am seeing the issue where https is being rewritten to http.
Redirecting port 80 to 443 at apache is not an option. As I read through other issues, I see that thr are plenty that speak of dwindling support for port 80 in corporate network environments. My work environment is no exception. If I open port 80, I'll get angry emails.
A webapp like jenkins needs to honor whatever infrastructure is placed upstream from it. Please do not rewrite URLs. You cannot know what operators must do to make things work in their environments, and it's not your job to have an opinion on it.
Sample login (redacted):
POST /j_acegi_security_check HTTP/1.1
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0
Accept-Encoding: gzip, deflate, br
Cookie: iconSize=16x16; jenkins-timestamper-offset=21600000; screenResolution=1440x900; JSESSIONID.a5761e5e=node0yhyguo9gmmz87vd5k02jlntr130.node0; JSESSIONID.bab614ae=node011mhw1v72qpxezxrvpnfa4bvw1.node0; JSESSIONID.6cca6ef5=node01of5t1znyg5421ape7vtgvhqe91.node0; JSESSIONID.21329fb7=node0vutsioe817odznpys8dxcm8t15.node0; JSESSIONID.a569f2e9=node01rwntrdy6tc9y14owwu2r31nyp32.node0
j_username=myuser&j_password=mypass&from=%2Fview%2Fopenbook%2F&Submit=Sign+inHTTP/1.1 302 Found
Date: Mon, 15 Apr 2019 16:28:37 GMT
Expires: Thu, 01 Jan 1970 00:00:00 GMT