개발 ON
  • [Troubleshooting] SSL 인증서 및 도메인 발급 이후 HTTP 기본 페이지로 나오는 문제
    2024년 09월 14일 00시 45분 51초에 업로드 된 글입니다.
    작성자: 이주여이

    공인 IP:포트로 접근했을 때는 잘 됐었다. 그러나 SSL 인증서 발급하고나서부터 기본 페이지가 나오는 게 아닌가..

     

    처음엔 설정 파일에서 documentRoot 경로를 dockerfile에서 작성했던 경로로 똑같이 바꾸는 바보 짓도 했었는데.. 생각해보니 공인 IP:Port로는 잘나오고 SSL 인증서 발급하자마자 안됐다?

     

    프록시 쪽 문제라는 생각이 들었고 이 전에 Rocky Linux에서 SSL 인증서 발급받을 때 어떻게 했는지 찾아보니 아래 문구가 더 적혀져 있었다.

     

    ProxyPreserveHost On
    ProxyPass / ${라즈베리파이 IP 주소 }:${컨테이너 포트 }/
    ProxyPassReverse / ${라즈베리파이 IP 주소 }:${컨테이너 포트 }/

     

    이 부분을 추가하자.

     

    파일은 /etc/apache2/sites-available/000-default-le-ssl.conf 이다.

     

    
    <IfModule mod_ssl.c>
    <VirtualHost *:443>
            # 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/localhost/htdocs/
    
            # 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
    
    ServerName todolist.n-e.kr
    SSLCertificateFile /etc/letsencrypt/live/todolist.n-e.kr/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/todolist.n-e.kr/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
    
    ProxyPreserveHost On
    ProxyPass / http://192.168.0.47:5221/
    ProxyPassReverse / http://192.168.0.47:5221/
    </VirtualHost>
    </IfModule>
    

     

    나는 192.168.0.47이 라즈베리파이 IP 주소이며 5221은 배포한 도커 컨테이너의 포트이다.

    자신에게 맞게 적어주고 저장하자.

     

    그리고 바로 restart 돌리지말고 mod_proxy가 활성화되어 있는지 확인도 해주자.

     

    a2enmod proxy             # mod_proxy 활성화 여부
    a2enmod proxy_http        # mod_proxy 활성화
    systemctl restart apache2 # Apache 재시작

     

    이후 확인하면 잘나오는 것을 확인할 수 있다.

     

    댓글