{"id":18756933,"url":"https://github.com/aiursoftweb/static","last_synced_at":"2025-08-10T16:37:19.448Z","repository":{"id":189069104,"uuid":"679613452","full_name":"AiursoftWeb/Static","owner":"AiursoftWeb","description":"Static is a simple static files HTTP server, as a global tool. Mirror of: https://gitlab.aiursoft.cn/aiursoft/static","archived":false,"fork":false,"pushed_at":"2025-04-10T06:19:29.000Z","size":445,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-13T02:03:49.158Z","etag":null,"topics":["static","webserver","website"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AiursoftWeb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-17T08:24:56.000Z","updated_at":"2025-04-10T06:19:33.000Z","dependencies_parsed_at":"2023-11-24T05:23:58.290Z","dependency_job_id":"0fe888ae-a338-4c4a-9e2f-f67873db95c6","html_url":"https://github.com/AiursoftWeb/Static","commit_stats":null,"previous_names":["aiursoftweb/static"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AiursoftWeb%2FStatic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AiursoftWeb%2FStatic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AiursoftWeb%2FStatic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AiursoftWeb%2FStatic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AiursoftWeb","download_url":"https://codeload.github.com/AiursoftWeb/Static/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248654096,"owners_count":21140236,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["static","webserver","website"],"created_at":"2024-11-07T17:38:46.974Z","updated_at":"2025-04-13T02:04:04.455Z","avatar_url":"https://github.com/AiursoftWeb.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Aiursoft.Static\n\n[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitlab.aiursoft.cn/aiursoft/static/-/blob/master/LICENSE)\n[![Pipeline stat](https://gitlab.aiursoft.cn/aiursoft/static/badges/master/pipeline.svg)](https://gitlab.aiursoft.cn/aiursoft/static/-/pipelines)\n[![Test Coverage](https://gitlab.aiursoft.cn/aiursoft/static/badges/master/coverage.svg)](https://gitlab.aiursoft.cn/aiursoft/static/-/pipelines)\n[![NuGet version (Aiursoft.Static)](https://img.shields.io/nuget/v/Aiursoft.Static.svg)](https://www.nuget.org/packages/Aiursoft.Static/)\n[![ManHours](https://manhours.aiursoft.cn/r/gitlab.aiursoft.cn/aiursoft/Static.svg)](https://gitlab.aiursoft.cn/aiursoft/Static/-/commits/master?ref_type=heads)\n[![Docker](https://img.shields.io/docker/pulls/aiursoft/static.svg)](https://hub.docker.com/r/aiursoft/static)\n\nStatic is a simple static files HTTP server, as a global tool.\n\n![overview](./screenshot.png)\n\n## Install\n\nRequirements:\n\n1. [.NET 9 SDK](http://dot.net/)\n\nRun the following command to install this tool:\n\n```bash\ndotnet tool install --global Aiursoft.Static\n```\n\n## Usage\n\nAfter getting the binary, run it directly in the terminal.\n\n```bash\n$ static.exe  --help\nDescription:\n  Start a static file server.\n\nUsage:\n  static [options]\n\nOptions:\n  -p, --port \u003cport\u003e                  The port to listen for the server. [default: 8080]\n  --path \u003cpath\u003e                      The folder to start the server. [default: .]\n  --allow-directory-browsing         Allow directory browsing the server files under the path. This options if conflict with --mirror. [default: False]\n  --mirror \u003cmirror\u003e                  The website to mirror. Automatically proxy the file if the file is not found in the server. This option if conflict with \n                                     --allow-directory-browsing. []\n  --cache-mirror                     Cache the mirrored files. This will save the mirrored files to the server's disk. [default: False]\n  --enable-webdav                    Enable WebDAV for the server. This is a read-only WebDAV server. [default: False]\n  --enable-webdav-write              Enable write access for the WebDAV server. This will allow the client to write files to the server. However, this requires the server \n                                     process to run with write permission. [default: False]\n  --not-found-page \u003cnot-found-page\u003e  Specifies a custom 404 page to be served when a requested file is not found. This file should reside in the server's root folder. If \n                                     this option is left blank or not set, a default 404 response will be returned. []\n  --version                          Show version information\n  -?, -h, --help                     Show help and usage information\n\nIt will start an HTTP server on http://localhost:8080.\n```\n\n## Install for all users\n\nYou can install this tool for all users by running the following command:\n\n```bash\nsudo apt install -y dotnet9\nsudo dotnet tool install Aiursoft.Static --tool-path /opt/static || sudo dotnet tool update Aiursoft.Static --tool-path /opt/static\nsudo chmod +x /opt/static/static\n```\n\nThen you can run the tool by `/opt/static/static`.\n\n## Install for systemd\n\nYou can make it a systemd service by creating a file `/etc/systemd/system/static.service` with the following content:\n\n```ini\n[Unit]\nDescription=Serves static files for '/mnt/data' on port 48466\nAfter=network.target\nWants=network.target\n\n# Before starting, run:\n# find /mnt/data -type d -print0 | sudo xargs -0 chmod 0755\n# find /mnt/data -type f -print0 | sudo xargs -0 chmod 0644\n# So www-data user can read the files\n# Also owner user can write to the files\n[Service]\nUser=www-data\nType=simple\nRestart=on-failure\nRestartSec=5s\nExecStart=/opt/static/static --path /mnt/data -p 48466 --allow-directory-browsing\nWorkingDirectory=/mnt/data\nLimitNOFILE=1048576\nKillSignal=SIGINT\nEnvironment=\"ASPNETCORE_ENVIRONMENT=Production\"\nEnvironment=\"DOTNET_PRINT_TELEMETRY_MESSAGE=false\"\nEnvironment=\"DOTNET_CLI_TELEMETRY_OPTOUT=1\"\nEnvironment=\"ASPNETCORE_FORWARDEDHEADERS_ENABLED=true\"\n\n[Install]\nWantedBy=multi-user.target\n```\n\nThen you can start the service by running:\n\n```bash\nsudo systemctl enable static\nsudo systemctl start static\nsudo systemctl status static\n```\n\n## Run in Docker\n\nFirst, install Docker [here](https://docs.docker.com/get-docker/).\n\nThen run the following commands in a Linux shell:\n\n```bash\nimage=aiursoft/static\nappName=static\nsudo docker pull $image\nsudo docker run -d --name $appName --restart unless-stopped -p 5000:5000 -v /var/www/$appName:/data $image\n```\n\nThat will start a web server at `http://localhost:5000` and you can test the app.\n\nThe docker image has the following context:\n\n| Properties  | Value                                  |\n|-------------|----------------------------------------|\n| Image       | aiursoft/static                        |\n| Ports       | 5000                                   |\n| Binary path | /app                                   |\n| Data path   | /data                                  |\n\n## Use Aiursoft.Static to build your own Docker image\n\nYou can use Aiursoft.Static to build your own Docker image. Here is an example of a `Dockerfile`:\n\nAssuming that you have a React project in the current directory that can be built with `yarn build` and the output is in the `build` directory.\n\n```Dockerfile\n# ============================\n# Prepare Build Environment\nFROM node:21-alpine as npm-env\nWORKDIR /src\nCOPY . .\nRUN yarn\nRUN yarn build\n\n# ============================\n# Prepare Runtime Environment\nFROM aiursoft/static\nCOPY --from=npm-env /src/build /data\n```\n\nIf you want to override the default behavior, simply add the `entrypoint` key to the service.\n\n```Dockerfile\nFROM aiursoft/static\nCOPY --from=npm-env /app/public /data\n\nENTRYPOINT [ \"/app/static\", \"--port\", \"5000\", \"--path\", \"/data\", \"--not-found-page\", \"/404.html\" ]\n```\n\n## Use Aiursoft.Static in docker-compose\n\nYou can use Aiursoft.Static in docker-compose. Here is an example of a `docker-compose.yml`:\n\n```yaml\nversion: '3.7'\n\nservices:\n  static:\n    image: aiursoft/static\n    volumes:\n      - your-volume:/data\n```\n\nIf you want to override the default behavior, simply add the `entrypoint` key to the service.\n\n```yaml\nversion: '3.7'\n\nservices:\n  static:\n    image: aiursoft/static\n    volumes:\n      - your-volume:/data\n    entrypoint: [\"sh\", \"-c\", \"/app/static --port 5000 --path /data/mirror/archive.ubuntu.com --allow-directory-browsing\"]\n```\n\n## How to contribute\n\nThere are many ways to contribute to the project: logging bugs, submitting pull requests, reporting issues, and creating suggestions.\n\nEven if you with push rights on the repository, you should create a personal fork and create feature branches there when you need them. This keeps the main repository clean and your workflow cruft out of sight.\n\nWe're also interested in your feedback on the future of this project. You can submit a suggestion or feature request through the issue tracker. To make this process more effective, we're asking that these include more information to help define them more clearly.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faiursoftweb%2Fstatic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faiursoftweb%2Fstatic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faiursoftweb%2Fstatic/lists"}