{"id":23297421,"url":"https://github.com/ikrong/mini-http","last_synced_at":"2025-04-06T19:53:56.816Z","repository":{"id":149371611,"uuid":"621771209","full_name":"ikrong/mini-http","owner":"ikrong","description":"golang static server. a minimal static server.","archived":false,"fork":false,"pushed_at":"2024-10-17T02:38:37.000Z","size":597,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-13T01:53:24.359Z","etag":null,"topics":["golang","http","http-server","https","https-server","server","static","static-server"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/ikrong/mini-http","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ikrong.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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-03-31T10:56:27.000Z","updated_at":"2024-07-14T04:05:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"0e3bcf91-bd61-4a6b-a4b8-db28ec23eaae","html_url":"https://github.com/ikrong/mini-http","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikrong%2Fmini-http","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikrong%2Fmini-http/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikrong%2Fmini-http/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikrong%2Fmini-http/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ikrong","download_url":"https://codeload.github.com/ikrong/mini-http/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247543609,"owners_count":20955865,"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":["golang","http","http-server","https","https-server","server","static","static-server"],"created_at":"2024-12-20T07:17:37.756Z","updated_at":"2025-04-06T19:53:56.794Z","avatar_url":"https://github.com/ikrong.png","language":"Go","readme":"## 一个非常轻量的静态资源服务器\n\n这个静态服务器的主要目的就是为了部署静态资源，也只具有静态访问功能，不适用于接口开发或者资源重定向。\n\n项目地址：\n\n* [https://github.com/ikrong/mini-http](https://github.com/ikrong/mini-http)\n* [https://hub.docker.com/r/ikrong/mini-http](https://hub.docker.com/r/ikrong/mini-http)\n\n目前支持的功能如下\n\n- [x] 支持静态资源访问\n- [x] 单页面路由\n- [x] 支持端口自定义\n- [x] 支持https配置\n- [x] 支持多域名配置\n- [x] 支持自定义404页面\n- [x] 支持gzip\n- [x] 支持api代理\n\n## 使用方法\n\n```shell\ndocker run -ti --rm --init -p 80:80 ikrong/mini-http\n```\n\n## 示例\n\n1. 部署一个本地静态服务器，你可以这样启动\n\n```shell\ndocker run -ti --rm --init -p 80:80 ikrong/mini-http\n```\n\n2. 使用本地静态文件\n\n```shell\ndocker run -ti --rm --init \\\n    -p 80:80 \\\n    -v /local/dir/:/www/ \\\n    ikrong/mini-http\n```\n\n3. 使用其他端口\n\n```shell\ndocker run -ti --rm --init \\\n    -p 8080:80 \\\n    -v /local/dir/:/www/ \\\n    ikrong/mini-http\n```\n\n4. 启动 `https` 服务器\n\n```shell\ndocker run -ti --rm --init \\\n    -p 443:443 \\\n    -v /localhost/cert/:/cert/ \\\n    ikrong/mini-http \\\n    /serve \\\n        --domain localhost \\\n        --cert /cert/cert.pem \\\n        --key /cert/cert.key\n```\n\n\u003e --domain 参数是告诉程序通过 `localhost` 域名访问服务\n\u003e \n\u003e --cert 参数是告诉程序使用哪个证书\n\u003e \n\u003e --key 参数是告诉程序使用哪个证书私钥\n\u003e \n\n4. 同时绑定多个域名\n\n\n```shell\ndocker run -ti --rm --init \\\n    -p 80:80 \\\n    ikrong/mini-http \\\n    /serve \\\n        --domain localhost \\\n        --domain example.com\n```\n\n\u003e 可以指定多对 domain 参数来绑定多个域名\n\n5. 多个域名指定多个静态资源\n\n```shell\ndocker run -ti --rm --init \\\n    -p 80:80 \\\n    -v /res/:/html/ \\\n    ikrong/mini-http \\\n    /serve \\\n        --domain localhost \\\n        --root /html/localhost/:/html/localhost/ \\\n        --domain example.com \\\n        --root /html/example.com/:/html/example.com/\n```\n\n\u003e 每一个 domain 后面都可以依次跟一个 root 来指定静态资源目录\n\u003e\n\u003e domain cert key root 这四个参数 domain 是必选，其他三个选填\n\u003e\n\u003e 可以设置多组，以支持多个域名多个静态资源\n\n6. 单页面应用\n\n```shell\ndocker run -ti --rm --init \\\n   -p 80:80 \\\n   ikrong/mini-http \\\n   /serve \\\n     --domain localhost \\\n     --mode history\n```\n\n\u003e mode 参数设置为 history 可以让对应的 domain 支持单页面应用访问\n\n7. API代理\n\n有时候，后端可能部署在其他域名下，直接访问存在跨域，跨域通过API代理，来规避跨域\n\n```shell\ndocker run -ti --rm --init \\\n   -p 80:80 \\\n   ikrong/mini-http \\\n   /serve \\\n     --domain localhost \\\n     --proxy /api:https://example.com/api \\\n     --skip-tls-verify true\n```\n\n\u003e proxy 参数跨域配置请求路径 /api 下的所有路径全部重定向到 https://example.com/api 路径下\n\n## LICENSE\n\nMIT License","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fikrong%2Fmini-http","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fikrong%2Fmini-http","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fikrong%2Fmini-http/lists"}