Apache 서버 뒤에서 Jenkins (Port 8080)와 SonarQube (Port 9000)의 두 가지 서비스를 실행하고 있습니다.
내 아파치 구성은 다음과 같습니다.
<VirtualHost *:80>
  ServerName server
  Redirect permanent / https://server.domain.com/
</VirtualHost>
<VirtualHost *:80>
  ServerName server.domain.com
  Redirect permanent / https://server.domain.com/
</VirtualHost>
<VirtualHost *:443>
  ServerName server.domain.com
  SSLEngine on
  SSLCertificateFile /etc/ssl/certs/server.crt
  SSLCertificateKeyFile /etc/ssl/private/server.key
  ProxyPass        /jenkins http://localhost:8080/jenkins nocanon
  ProxyPassReverse /jenkins http://localhost:8080/jenkins
  ProxyPassReverse /jenkins http://server.domain.com/jenkins
  ProxyPassReverse /jenkins https://server.domain.com/jenkins
  ProxyPass        /sonar http://localhost:9000/sonar nocanon
  ProxyPassReverse /sonar http://localhost:9000/sonar
  AllowEncodedSlashes NoDecode
  ProxyRequests Off
  ProxyPreserveHost On
  <Proxy http://localhost:8080/*>
    Order deny,allow
    Allow from all
  </Proxy>
</VirtualHost>
Jenkins 가이 메시지에 대해 불평하는 것을 제외하고는 모든 것이 잘 작동하는 것 같습니다. 리버스 프록시 설정이 손상된 것 같습니다.
Jenkins에서 제공 한 ReverseProxySetupMonitor 테스트를 실행하면 http가 https로 대체되지 않으므로 리버스 프록시가있는 것이 올바르게 설정되지 않았다는 오류 메시지가 표시됩니다.
$ curl -iLk -e https://server.domain.com/jenkins/manage https://server.domain.com/jenkins/administrativeMonitor/hudson.diagnosis.ReverseProxySetupMonitor/test
[...]
404 http://server.domain.com/jenkins/manage vs. https://server.domain.com/jenkins/manage
[...]
이것은 서버에서 SSL을 활성화 한 후에 만 나타났습니다 (이제 자체 서명 된 인증서를 사용하고 있습니다).
질문 :
Jenkins가 만족하도록 리버스 프록시 설정을 어떻게 수정합니까? 아파치 구성 파일을 개선하는 방법에 대한 팁 보너스 포인트.
다음 두 가지 관련 질문을 이미 확인했습니다.
답변
Wiki Jenkins 의이 페이지 에서는 2014 년 7 월 에 Jenkins 리버스 프록시에 권장되는 구성을 언급했습니다 . 누락 된 매개 변수가 RequestHeader set X-Forwarded-Proto "https"와RequestHeader set X-Forwarded-Port "443"
그래서 구성은
<VirtualHost *:443>
    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/cert.pem
    ServerAdmin  webmaster@localhost
    ProxyRequests     Off
    ProxyPreserveHost On
    AllowEncodedSlashes NoDecode
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
    ProxyPass         /  http://localhost:8080/ nocanon
    ProxyPassReverse  /  http://localhost:8080/
    ProxyPassReverse  /  http://www.example.com/
    RequestHeader set X-Forwarded-Proto "https"
    RequestHeader set X-Forwarded-Port "443"
</VirtualHost>
답변
Jenkins 용 Windows Apache 프론트 엔드 설정
주요 차이점은 다음과 같습니다.
- 임시 인증서를 설정하는 방법
 - SSL 캐시가 없다는 아파치 윙 중지
 
내 설정 :
- 
설치는 d : \ (c : \ 아님)-필요에 맞게 조정하십시오.
 - 
Jenkins는 포트 8080에 있습니다.
 - 
Apache httpd-2.4.18-win64-VC14.zip ( http://www.apachelounge.com/download/에서 )을 d : \로 압축 해제 하십시오 .
 - 
OpenSSL Win64OpenSSL_Light-1_0_2f.exe ( http://slproweb.com/products/Win32OpenSSL.html )를 d : \ OpenSSL-Win64에 설치하십시오.
 - 
SSL 인증서를 작성하십시오.
- 
OpenSSL bin 디렉토리로 cd하고 매직을 실행하십시오.
pushd d:\OpenSSL-Win64\bin set OPENSSL_CONF=openssl.cfg openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout server.key -out server.crt 
 - 
 - 
d. \ OpenSSL-Win64 \ bin에서 server : * 파일을 D : \ Apache24 \ conf로 복사하십시오.
 - 
d : \ Apache24 \ conf \ httpd.conf를 편집하십시오.
- 
“c : /”를 검색하고 “d : /”로 바꿉니다.
 - 
“Listen 443″을 추가하여 “Listen 80″행 다음에 변경하십시오.
Listen 80 Listen 443 - 
다음 줄의 주석을 해제하십시오.
LoadModule headers_module modules/mod_headers.so LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_ajp_module modules/mod_proxy_ajp.so LoadModule proxy_http_module modules/mod_proxy_http.so LoadModule rewrite_module modules/mod_rewrite.so LoadModule socache_shmcb_module modules/mod_socache_shmcb.so LoadModule ssl_module modules/mod_ssl.so LoadModule vhost_alias_module modules/mod_vhost_alias.so - 
“#ServerName www.example.com:80″을 다음과 같이 업데이트하십시오.
ServerName myserver.mydomain:80 - 
끝에 이것을 추가하십시오 :
<IfModule socache_shmcb_module> SSLSessionCache "shmcb:logs/ssl_scache(512000)" </IfModule> <VirtualHost *:80> ServerName myserver Redirect permanent / https://myserver.mydomain/ </VirtualHost> <VirtualHost *:80> ServerName myserver.mydomain Redirect permanent / https://myserver.mydomain/ </VirtualHost> <VirtualHost *:443> SSLEngine on SSLCertificateFile conf/server.crt SSLCertificateKeyFile conf/server.key ServerAdmin me@mydomain ProxyRequests Off ProxyPreserveHost On AllowEncodedSlashes NoDecode <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass / http://localhost:8080/ nocanon ProxyPassReverse / http://localhost:8080/ ProxyPassReverse / http://myserver.mydomain/ RequestHeader set X-Forwarded-Proto "https" RequestHeader set X-Forwarded-Port "443" </VirtualHost> 
 - 
 
포트 8080에서 Jenkins 수신을 중지하지 않았으므로 아파치가 실패해도 계속 연결할 수 있습니다. https 사용의 목표는 매개 변수를 숨기는 것입니다.