
Lighttpd 서버에서 SSL을 구성하는 방법
2022-10-18 last update
7 minutes reading virtualhost https SSL webserver lighttpdSSL로 실행되는 모든 사이트는 기본 포트 443에서 https 프로토콜을 사용합니다. SSL은 서버와 클라이언트 간의 데이터를 암호화하여 안전한 데이터 통신을 제공합니다. 이전 기사에서 CentOS/RHEL 시스템의 installing lighttpd 및 creating virtualhosts에 대해 설명했습니다. 이 문서는 Lighttpd 서버에서 SSL을 구성하는 데 도움이 될 것입니다. 이 예에서는 자체 서명된 인증서를 사용하고 있습니다. Apache/HTTPD에서 configure ssl을 찾고 있다면 this article 해야 합니다.
1단계: 인증서 서명 요청(CSR) 생성
SSL 인증서를 생성하기 위한 첫 번째 요구 사항은 개인 키와 CSR을 생성하는 것입니다. CSR은 공개 키를 포함하여 도메인에 대한 모든 세부 정보가 있는 파일입니다. 먼저 csr과 key를 생성할 디렉토리를 생성합니다.# mkdir /etc/lighttpd/ssl/ # cd /etc/lighttpd/ssl/이제 다음 명령으로 CSR 및 키 파일을 생성합니다. 도메인에 따라 example.com.key 및 example.com.csr 파일의 이름을 변경합니다. 이 명령은 도메인에 대한 정보를 입력하도록 요청합니다. Read more CSR 생성에 대해.
# openssl req -new -newkey rsa:2048 -nodes -keyoutexample.com.key -outexample.com.csr
Generating a 2048 bit RSA private key ....+++ ...............+++ writing new private key to 'example.com.key' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [XX]:IN State or Province Name (full name) []:Delhi Locality Name (eg, city) [Default City]:Delhi Organization Name (eg, company) [Default Company Ltd]:TecAdmin Inc. Organizational Unit Name (eg, section) []:web Common Name (eg, your name or your server's hostname) []:example.com Email Address []:[email protected] Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []:[Leave Blank] An optional company name []:[Leave Blank]
2단계: CA에서 인증서 요청
CSR을 생성한 후 Geotrust, Comodo, Digicert 또는 GoDaddy 등과 같은 인증서 제공자에게 SSL 인증서를 요청하거나 내부 사용을 위해 self signed certificate을 생성합니다. 프로덕션 사이트에는 권장하지 않습니다.# openssl x509 -req -days 365 -in현재 디렉토리에 example.com.crt라는 이름의 인증서 파일이 생성됩니다. 이제 키 파일과 인증서를 하나의 파일에 결합하여 pem 파일을 만듭니다example.com.csr -signkeyexample.com.key -outexample.com.crt
# cat example.com.key example.com.crt > example.com.pem
3단계: SSL로 VirtualHost 설정
Lighttpd 구성 파일/etc/lighttpd/lighttpd.conf를 편집하고 다음 값을 추가합니다.$SERVER["socket"] == ":443" { ssl.engine = "enable" ssl.pemfile = "/etc/lighttpd/ssl/.net.pem" # ssl.ca-file = "/etc/lighttpd/ssl/CA_issuing.crt" server.name = "site1..net" server.document-root = "/sites/vhosts/site1..net/public" server.errorlog = "/var/log/lighttpd/site1..net.error.log" accesslog.filename = "/var/log/lighttpd/site1..net.access.log" }
4단계: 구성 확인 및 Lighttpd 다시 시작
lighttpd 서비스를 시작하기 전에 구성 파일의 구문을 확인하십시오.# lighttpd -t -f /etc/lighttpd/lighttpd.conf Syntax OK모든 구문이 정상이면 서비스를 다시 시작할 수 있습니다.
# service lighttpd restart