feat(nasp/g): introduce code-server

see also: 517c5fc27d
This commit is contained in:
Dict Xiong 2024-05-30 15:13:19 +08:00
parent 2ae1dc3031
commit 17402e4bef
2 changed files with 27 additions and 0 deletions

View File

@ -254,6 +254,30 @@ in
%nasp ALL = (root) NOPASSWD: /run/current-system/sw/bin/shutdown
%nasp ALL = (root) NOPASSWD: /run/current-system/sw/bin/ip
'';
## nginx
services.nginx = {
enable = true;
virtualHosts."default" = {
serverName = "_";
default = true;
locations."/" = {
return = "404";
};
};
virtualHosts."code-server" = {
serverName = "proxy.nasp.fit";
locations."~ ^/${config.networking.hostName}/([A-Za-z0-9]+)/(.*)" = {
extraConfig = ''
rewrite "^/${config.networking.hostName}/([A-Za-z0-9]+)/(.*)" /$2 break;
proxy_pass "http://unix:/home2/run/$1.sock";
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_set_header Accept-Encoding gzip;
'';
};
};
};
}))
]);
}

View File

@ -79,6 +79,9 @@ if [[ "$ret" == "1" ]]; then
eval "$base_command"
echo "Container $container_name started. You can use the following command to get in:"
echo "sudo docker exec -it $container_name bash"
if [[ "$image_name" == "git.nasp.fit/nasp/nasp-ubuntu" ]]; then
sudo docker exec -it $container_name code.sh
fi
else
echo "Aborted."
fi