add myurls
This commit is contained in:
parent
0bf654dc6e
commit
92ecf9e135
|
@ -0,0 +1,17 @@
|
|||
FROM golang:1.15-alpine AS build
|
||||
ARG TARGETARCH
|
||||
RUN apk add --update git
|
||||
RUN git clone https://github.com/CareyWang/MyUrls /app
|
||||
WORKDIR /app
|
||||
RUN go env -w GO111MODULE="on" && go env -w GOPROXY="https://goproxy.cn,direct"
|
||||
RUN go mod tidy
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -o myurls main.go
|
||||
|
||||
FROM alpine:latest
|
||||
WORKDIR /app
|
||||
COPY --from=build /app/myurls ./
|
||||
COPY --from=build /app/public/* ./public/
|
||||
COPY start.sh ./
|
||||
|
||||
EXPOSE 8002
|
||||
CMD [ "sh", "-c", "/app/start.sh" ]
|
|
@ -0,0 +1,25 @@
|
|||
# myurls
|
||||
|
||||
GitHub [stilleshan/dockerfiles](https://github.com/stilleshan/dockerfiles)
|
||||
Docker [stilleshan/myurls](https://hub.docker.com/r/stilleshan/myurls)
|
||||
> *docker image support for X86 and ARM*
|
||||
|
||||
## 简介
|
||||
基于 [CareyWang/MyUrls](https://github.com/CareyWang/MyUrls) 短链接程序的修改版容器镜像,主要解决方便的自定义前端域名以及 ARM64 架构的支持.
|
||||
|
||||
## 部署
|
||||
### docker compose
|
||||
> 由于需要搭配`redis`使用,建议使用`docker compose`部署.
|
||||
|
||||
- 下载 [docker-compose.yml](https://raw.githubusercontent.com/stilleshan/dockerfiles/main/myurls/docker-compose.yml)
|
||||
- 修改`MYURLS_DOMAIN`为你的域名
|
||||
- 修改`MYURLS_TTL`为短链接有效期(单位:天)
|
||||
```shell
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
### nginx 反代
|
||||
需要搭配 nginx 反向代理配置 HTTPS 证书使用,参考`domain.conf`配置文件,注意需要修改`域名`,`证书路径`,`日志路径`
|
||||
|
||||
## 参考
|
||||
- [CareyWang/MyUrls](https://github.com/CareyWang/MyUrls)
|
|
@ -0,0 +1,22 @@
|
|||
version: "3"
|
||||
services:
|
||||
myurls:
|
||||
image: stilleshan/myurls:latest
|
||||
# container_name: myurls
|
||||
environment:
|
||||
- MYURLS_DOMAIN=s.ops.ci
|
||||
- MYURLS_TTL=365
|
||||
volumes:
|
||||
- ./data/myurls/logs:/app/logs
|
||||
ports:
|
||||
- "8002:8002"
|
||||
depends_on:
|
||||
- redis
|
||||
restart: always
|
||||
|
||||
redis:
|
||||
image: redis:latest
|
||||
# container_name: myurls-redis
|
||||
volumes:
|
||||
- ./data/redis:/data
|
||||
restart: always
|
|
@ -0,0 +1,49 @@
|
|||
server {
|
||||
listen 80;
|
||||
server_name s.ops.ci;
|
||||
return 301 https://s.ops.ci$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name s.ops.ci;
|
||||
index index.php index.html index.htm;
|
||||
gzip on;
|
||||
|
||||
ssl_certificate /usr/local/nginx/conf/ssl/ops.ci.cer;
|
||||
ssl_certificate_key /usr/local/nginx/conf/ssl/ops.ci.key;
|
||||
ssl_trusted_certificate /usr/local/nginx/conf/ssl/ops.ci.cer;
|
||||
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4;
|
||||
ssl_ecdh_curve secp384r1;
|
||||
ssl_session_timeout 10m;
|
||||
ssl_session_cache builtin:1000 shared:SSL:10m;
|
||||
ssl_session_tickets off;
|
||||
resolver 8.8.8.8 8.8.4.4 valid=60s ipv6=off;
|
||||
resolver_timeout 5s;
|
||||
add_header Strict-Transport-Security "max-age=63072000" always;
|
||||
|
||||
location / {
|
||||
proxy_redirect off;
|
||||
proxy_pass http://127.0.0.1:8002;
|
||||
|
||||
add_header 'Access-Control-Allow-Origin' '*';
|
||||
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-Ssl on;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Frame-Options SAMEORIGIN;
|
||||
|
||||
client_max_body_size 100m;
|
||||
client_body_buffer_size 128k;
|
||||
}
|
||||
|
||||
access_log /home/wwwlogs/s.ops.ci.access.log main;
|
||||
error_log /home/wwwlogs/s.ops.ci.error.log warn;
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
#/bin/sh
|
||||
|
||||
sed -i "s#http://example.com#https://${MYURLS_DOMAIN}#g" /app/public/index.html
|
||||
|
||||
/app/myurls -domain ${MYURLS_DOMAIN} -conn redis:6379 -ttl ${MYURLS_TTL}
|
Loading…
Reference in New Issue