Official SonarQube Doc Link: Securing the Server Behind a Proxy
This section helps you configure the SonarQube Server if you want to run it behind a proxy. This can be done for security concerns or to consolidate multiple disparate applications.
Table of Contents
서버 설정
SonarQube 서버를 HTTPS 프로토콜 상에서 실행하기 위해서는 표준적인 리버스 프록시 인프라스트럭처를 만들어야 합니다. 리버스 프록시는 모든 HTTP 요청 헤더에서 \"X\_FORWAREDED\_PROTO: https:\"로 설정되어야 합니다. 이 속성이 없는 경우, SonarQube에서 보내는 리다이렉션은 HTTP로 떨어집니다.
아파치 프록시 사용하기
다음의 상황을 가정합니다:
- 여러분이 이미 Apache 2 를 module mode_proxy로 설치 완료
- SonarQube 서버가 http://private\_sonar\_host:sonar\_port/ 에서 실행 중
- www.public_sonar.com로 virtual host 설정 완료
www.public\_sonar.com virtual host의 HTTPd 환경 설정 파일을 수정합니다. 다음 내용을 포함시켜 SonarQube를 mod\_proxy를 통해 http://www.public\_sonar.com/에 접근할 수 있도록 합니다:
````
ProxyRequests Off
ProxyPreserveHost On
<VirtualHost *:80>
ServerName www.public_sonar.com
ServerAdmin admin@somecompany.com
ProxyPass / http://private_sonar_host:sonar_port/
ProxyPassReverse / http://www.public_sonar.com/
ErrorLog logs/somecompany/sonar/error.log
CustomLog logs/somecompany/sonar/access.log common
</VirtualHost>
````
Apahce 환경 설정은 여러분이 사용하는 어플리케이션의 요구사항과, SonarQube를 외부로 노출시키기 원하는 방법에 따라 달라질 수 있습니다. Apache HTTPd와 mod\_proxy에 대한 세부적인 내용은 [http://httpd.apache.org](http://httpd.apache.org)를 참조합니다.
Nginx 사용하기
다음의 상황을 가정합니다:
- Nginx 설치 완료
- www.somecompany.com으로 Virtual Host 운영 중
- SonarQube는 http://sonarhost:sonarport/에서 운영 중
Nginx 환경 파일을 수정합니다. http://www.somecompany.com/를 통해 SonarQube에 접근하기 위해 다음 내용을 추가합니다.
````
# the server directive is nginx's virtual host directive
server {
# port to listen on. Can also be set to an IP:PORT
listen 80;
# sets the domain[s] that this vhost server requests for
server_name www.somecompany.com;
location / {
proxy_pass http://sonarhost:sonarport;
}
}
````
Nginx 환경 설정은 여러분의 어플리케이션 요구사항, SonarQube를 외부로 노출시키기 원하는 방법에 따라 달라질 수 있습니다. Nginx와 관련된 세부적인 내용은
[https://www.nginx.com/resources/admin-guide/reverse-proxy/](https://www.nginx.com/resources/admin-guide/reverse-proxy/)를 참조합니다.
Sonarqube는 2048자 이상의 URL을 요청하는 경우가 있으므로 max URL length를 증가해야 할 수도 있습니다.
IIS 사용하기
다음 링크를 참조합니다: [http://blog.jessehouwing.nl/2016/02/configure-ssl-for-sonarqube-on-windows.html](http://blog.jessehouwing.nl/2016/02/configure-ssl-for-sonarqube-on-windows.html)