다음으로 이동
cd /etc/nginx
site-available
안에 있는 default.conf
를 복사하여 새로 생성
cp default.conf domain.com.conf
복사한 파일 수정
server {
listen 80;
server_name domain.com;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header x-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
}
심볼릭 링크 생성
sudo ln -s /etc/nginx/sites-available/domain.com.conf /etc/nginx/sites-enabled
nginx
문법 체크
sudo nginx -t
nginx
재시작
sudo service nginx restart
- Centos
Centos
에서는 명령어를systemctl nginx restart
식으로 해야함127.0.0.1
대신에localhost
인식 가능site-available
이 기존에 없으면conf.d
에서 새로 생성하면 된다
- Ubuntu
Ubuntu
에서는localhost
인식이 안되길래(?)127.0.0.1
로 고정
에러 대응
(업데이트 2023-06-13)
rewrite or internal redirection cycle while internally redirecting to "/index.html"
위 처럼 계속 무한 순환 하는 오류가 나올 때 확인해야하는 것이 있다.
실행하려는 애플리케이션 폴더의 사용자가 누구인지 확인하고 nginx.conf
에서 user
를 해당 값으로 수정하고 재시작한다.
기본값은 nginx
로 되어있다. (기본값이여도 잘되던것이 신규로 서버 구성한 것은 안됨... nginx 업데이트가 있었나 ..?)
'Server > Nginx' 카테고리의 다른 글
Let's Encrypt + Nginx SSL(https 443) 적용하기 (0) | 2023.07.29 |
---|---|
Nginx 설치 (0) | 2023.03.20 |