로그인

  • 목록
  • 아래로
  • 위로
  • 쓰기
  • 검색

정보&강의 The plain HTTP request was sent to HTTPS port 에러 해결법


400 Bad Request
The plain HTTP request was sent to HTTPS port
nginx

 

 

nginx로 서버를 운영할 때 가급적  ssl이 적용된 443포트로 서버를 운영한다.

이때 Edgerouter의 경우 NAT를 설정하면 표준 80, 443 포트라도 NAT를 거치는 포트가 비표준 포트로 변경이 되는 것 같다.

 

그래서 기존의 nginx 설정에서 고전적인 http에서 https로의 리다이렉션이 수행이 되지 않고 해당 오류가 발생되는 것이다.

 

# HTTP
server {
    listen 80;
    server_name sample.or.kr www.sample.or.kr;

    location / {
       return 301 https://$server_name$request_uri;
    }
}

# HTTPS
server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  server_name sample.or.kr www.sample.or.kr;
  error_page 497 https://$server_name$request_uri;
  root /home/jinmok/public_html;
  index index.php index.html;
}

 

이때 https server 설정에 아래 명령어를 입력하고 nginx 서버를 재시작하면 된다.

 

error_page 497 https://$server_name$request_uri;

 

Edgerouter에서 NAT를 설정하면 표준포트가 비표준포트로 인식된다는 게 핵심이다.

 


이런 글도 찾아보세요!

공유

facebooktwitterpinterestbandkakao story
퍼머링크

댓글 0

권한이 없습니다. 로그인

신고

"님의 댓글"

이 댓글을 신고 하시겠습니까?

삭제

"님의 댓글"

이 댓글을 삭제하시겠습니까?