Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Add ".log" suffix for user-stdout/user-stderr/user-all log files #5272

Merged
merged 3 commits into from
Feb 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/log-manager/src/nginx/get_log_content.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,6 @@ end

-- Refer https://www.openwall.com/lists/oss-security/2020/03/18/1. set_uri may cause security issue.
-- Here we need to make sure the log_path is valid
ngx.req.set_uri_args("filename="..log_name)
ngx.req.set_uri("/~/"..string.sub(path.abspath(log_path), string.len(file_prefix) + 1), true)

11 changes: 10 additions & 1 deletion src/log-manager/src/nginx/nginx.conf.default
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ server {
location ~ ^/api/v1/logs/(.*)$ {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET';
add_header Content-Disposition 'attachment';

limit_except GET {
deny all;
}
Expand All @@ -86,6 +86,15 @@ server {
add_header Accept-Ranges bytes;
add_header Access-Control-Allow-Origin *;
rewrite ^/~/(.*)$ $1 break;
rewrite_by_lua_block {
local args = ngx.req.get_uri_args()
local filename = args["filename"]
if string.match(filename, "^user%-.*$") then
ngx.header["Content-Disposition"] = "attachment; filename=\""..filename..".log\""
else
ngx.header["Content-Disposition"] = "attachment"
end
}

root /usr/local/pai/logs/;
}
Expand Down