-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
- Ubuntu 24.04 에 설치했을때 기본으로 제공되는 파일
- ssl 관련 설정, private ip 주소는 gitignore로 관리
- nginx.logbat.info 도메인 추가 - nginx 가 로그를 삭제할 수 있도록 sudo 권한 부여 - lua를 사용해 API 구현
- 지정한 헤더가 존재하지 않을 경우 403 반환
nginx/sites-available/default
Outdated
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) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fastcgi.conf
와 동일한 파일 내용이 2개 들어가 있는 이유가 궁금합니당
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻 스크럼때 추가 설명 해주면 좋을 것 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋습니다!
* 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 반환
🚀 작업 내용
commit f15d890
)commit 646d600
)/count
와/reset
API를 생성했습니다. NGINX에서 로그를 관리할 수 있도록sudo
권한을 부여했으며, 관련 설정을 추가했습니다. (commit 30f39ca
)commit 7f934f4
)view.logbat.info
도메인을 추가했습니다. (commit f06663b
).gitignore
로 관리하도록 변경했습니다. (commit b9a8107
)commit 7e1a9e2
)📸 이슈 번호
👀 Focus Commits [Optional]
f15d890
: 외부 호출 보안 강화646d600
: 응답에서 파일명 제외30f39ca
: Lua API 생성✍ 궁금한 점
auth_header
,successCount
,errorCount
등 변수명이 명확한지 확인 부탁드립니다.