개발/리눅스
Apache와 Node.js 연결하기 (도메인 연결)
거구마말랭이
2024. 7. 1. 01:14
1. Apache 설정파일 수정
> vi /etc/httpd/conf/httpd.conf
아래 내용 입력 (include 되어있으면 생략)
include /etc/httpd/conf/vhost.conf
모듈 추가 (또는 주석 해제)
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
2. vhost.conf 파일 생성 및 내용 입력
> vi /etc/httpd/conf/vhost.conf
아래 내용 입력
<VirtualHost *:80>
ServerName sub.domain.com
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
</VirtualHost>
sub.domain.com로 들어가면 로컬호스트 3000번에서 돌아가고 있는 서버로 이동하도록(?)
포트번호는 노드가 돌아가고 있는 포트 입력
3. 아파치 재시작
> systemctl restart httpd
4. 노드 서버 구동 후 브라우저에서 확인
오류 해결
- 오류 내용:
Service Unavailable.
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
오류 해결:
노드 서버 포트가 http_port_t context(?)에 속해있는지 확인
> semanage port -l | grep http_port_t
없으면 추가
> semanage port -a -p tcp -t http_port_t 3000
- 참고 자료
- https://playon.tistory.com/87
- https://idchowto.com/?p=39274 (https 프록시 설정도 있음)