Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/#64 Nginx 요청 Count API 구현 #69

Merged
merged 7 commits into from
Aug 16, 2024
Merged

Feat/#64 Nginx 요청 Count API 구현 #69

merged 7 commits into from
Aug 16, 2024

Conversation

LuizyHub
Copy link
Member

🚀 작업 내용

  • feature: 외부에서 호출이 불가능하도록 보안을 강화했습니다. 지정된 헤더가 존재하지 않을 경우 403 상태 코드를 반환하도록 설정했습니다. (commit f15d890)
  • fix: 파일명이 응답에 포함되지 않도록 수정했습니다. (commit 646d600)
  • feature: Lua를 사용해 /count/reset API를 생성했습니다. NGINX에서 로그를 관리할 수 있도록 sudo 권한을 부여했으며, 관련 설정을 추가했습니다. (commit 30f39ca)
  • refactor: 중복된 코드를 제거하여 코드의 가독성과 유지보수성을 개선했습니다. (commit 7f934f4)
  • feature: view.logbat.info 도메인을 추가했습니다. (commit f06663b)
  • config: 현재 설정 정보를 업데이트했습니다. SSL 관련 설정과 private IP 주소는 .gitignore로 관리하도록 변경했습니다. (commit b9a8107)
  • config: NGINX 초기 설정을 추가했습니다. 이는 Ubuntu 24.04에 설치 시 기본으로 제공되는 파일을 기반으로 했습니다. (commit 7e1a9e2)

📸 이슈 번호

👀 Focus Commits [Optional]

  • f15d890: 외부 호출 보안 강화
  • 646d600: 응답에서 파일명 제외
  • 30f39ca: Lua API 생성

✍ 궁금한 점

  • 외부 호출을 차단하는 보안 로직이 적절하게 구현되었는지 검토 부탁드립니다.
  • auth_header, successCount, errorCount 등 변수명이 명확한지 확인 부탁드립니다.
  • Lua 스크립트의 구조와 NGINX 설정의 로직이 깔끔한지 피드백 부탁드립니다.
  • wiki에 Lua 설치와 같은 과정이 문서화 되어있습니다.
  • auth 값은 따로 공유드리겠습니다

- Ubuntu 24.04 에 설치했을때 기본으로 제공되는 파일
- ssl 관련 설정, private ip 주소는 gitignore로 관리
- nginx.logbat.info 도메인 추가
- nginx 가 로그를 삭제할 수 있도록 sudo 권한 부여
- lua를 사용해 API 구현
- 지정한 헤더가 존재하지 않을 경우 403 반환
@LuizyHub LuizyHub added 🚀 Config 의존성 관리, 빌드, 배포 등 개발 환경에 관련된 작업 ⭐️ Feat 새로운 기능이나 요청 labels Aug 15, 2024
@LuizyHub LuizyHub requested a review from a team August 15, 2024 19:58
@LuizyHub LuizyHub self-assigned this Aug 15, 2024
Comment on lines 112 to 140
location /count {
content_by_lua_block {
-- access.log의 라인 수를 세어 successCount로 사용
local handle_access = io.popen("wc -l /var/log/nginx/access.log")
local successCount = handle_access:read("*a")
handle_access:close()

-- error.log의 라인 수를 세어 errorCount로 사용
local handle_error = io.popen("wc -l /var/log/nginx/error.log")
local errorCount = handle_error:read("*a")
handle_error:close()

-- JSON 형식으로 응답
ngx.header.content_type = 'application/json';
ngx.say('{"successCount":'..successCount:gsub("%s+", "")..', "errorCount":'..errorCount:gsub("%s+", "")..'}')
}
}

location /count/reset {
content_by_lua_block {
-- 로그 파일 지우기
os.execute("sudo truncate -s 0 /var/log/nginx/access.log")
os.execute("sudo truncate -s 0 /var/log/nginx/error.log")

-- 204 상태 코드 반환
ngx.status = ngx.HTTP_NO_CONTENT
ngx.exit(ngx.HTTP_NO_CONTENT)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fastcgi.conf 와 동일한 파일 내용이 2개 들어가 있는 이유가 궁금합니당

Copy link
Member

@tidavid1 tidavid1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻 스크럼때 추가 설명 해주면 좋을 것 같아요!

Copy link
Member

@miiiinju1 miiiinju1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋습니다!

@LuizyHub LuizyHub merged commit 8ef2537 into dev Aug 16, 2024
1 check passed
@LuizyHub LuizyHub deleted the feat/#64 branch August 16, 2024 01:07
LuizyHub added a commit that referenced this pull request Aug 19, 2024
* config: init Nginx

- Ubuntu 24.04 에 설치했을때 기본으로 제공되는 파일

* config: 현재 설정 정보 업데이트

- ssl 관련 설정, private ip 주소는 gitignore로 관리

* feature: view.logbat.info 도메인 추가

* refactor: 중복 코드 제거

* featrue: lua를 사용해 count, reset API 생성

- nginx.logbat.info 도메인 추가
- nginx 가 로그를 삭제할 수 있도록 sudo 권한 부여
- lua를 사용해 API 구현

* fix: 파일명은 응답에 포함되지 않도록 변경

* feature: 외부에서 호출이 불가능하도록 보안 추가

- 지정한 헤더가 존재하지 않을 경우 403 반환
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 Config 의존성 관리, 빌드, 배포 등 개발 환경에 관련된 작업 ⭐️ Feat 새로운 기능이나 요청
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants