Files
user01 0f9e18c4df deploy: Apache2 리버스 프록시 설치 스크립트 추가
- Apache2 설치·모듈·HTTPS(certbot webroot)·vhost 자동 구성
- HTTP 전용 부트스트랩/테스트 설정 추가
- 기존 nginx 인증서 갱신 방식을 webroot로 자동 전환
- 짧은 주소 리다이렉트를 next.config.ts로 이동해 웹서버 공통화
2026-10-26 01:16:45 +09:00

88 lines
3.1 KiB
Plaintext

# __DOMAIN__ — Apache 2.4 리버스 프록시 (Next.js/yonggong)
# deploy/apache2/install.sh 가 __DOMAIN__, __DOMAIN_ALIAS__, __APP_PORT__ 를 치환해
# /etc/apache2/sites-available/__DOMAIN__.conf 로 설치합니다.
#
# 레거시 정적 자산(/addMarker.html, /res/, /blogload.js)은 /var/www/html 에서 계속 서비스합니다.
# 한글 도메인(용공협.kr)은 퓨니코드로 ServerAlias 에 함께 등록합니다.
<VirtualHost *:80>
ServerName __DOMAIN__
ServerAlias __DOMAIN_ALIAS__
DocumentRoot /var/www/html
# certbot(webroot) 인증서 갱신용
Alias /.well-known/acme-challenge/ /var/www/html/.well-known/acme-challenge/
<Directory /var/www/html/.well-known/acme-challenge>
Require all granted
</Directory>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
ErrorLog ${APACHE_LOG_DIR}/__DOMAIN__.error.log
CustomLog ${APACHE_LOG_DIR}/__DOMAIN__.access.log combined
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName __DOMAIN__
ServerAlias __DOMAIN_ALIAS__
Protocols h2 http/1.1
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/__DOMAIN__/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/__DOMAIN__/privkey.pem
SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
SSLHonorCipherOrder off
SSLSessionTickets off
Header always set Strict-Transport-Security "max-age=31536000"
DocumentRoot /var/www/html
<Directory /var/www/html>
Options -Indexes +FollowSymLinks
AllowOverride None
Require all granted
</Directory>
# certbot(webroot) 인증서 갱신용
Alias /.well-known/acme-challenge/ /var/www/html/.well-known/acme-challenge/
<Directory /var/www/html/.well-known/acme-challenge>
Require all granted
</Directory>
ProxyRequests Off
ProxyPreserveHost On
ProxyTimeout 120
# 레거시 정적 자산은 프록시하지 않고 /var/www/html 에서 직접 서비스
ProxyPass /addMarker.html !
ProxyPass /blogload.js !
ProxyPass /res/ !
ProxyPass /.well-known/ !
# 첨부 10개 × 50MB 업로드를 고려한 값 (앱 bodySizeLimit 60mb와 동일)
LimitRequestBody 62914560
<Location "/res/">
ExpiresActive On
ExpiresDefault "access plus 7 days"
Header set Cache-Control "public, max-age=604800"
</Location>
# Next.js 애플리케이션 (systemd: yonggong.service)
ProxyPass / http://127.0.0.1:__APP_PORT__/ upgrade=websocket
ProxyPassReverse / http://127.0.0.1:__APP_PORT__/
# Next.js가 HTTPS 요청임을 알 수 있도록 전달
RequestHeader set X-Forwarded-Proto "https"
ErrorLog ${APACHE_LOG_DIR}/__DOMAIN__.error.log
CustomLog ${APACHE_LOG_DIR}/__DOMAIN__.access.log combined
</VirtualHost>
</IfModule>