Skip to content

Commit 98c4a79

Browse files
committed
add shlink
1 parent e0eda3c commit 98c4a79

File tree

2 files changed

+291
-0
lines changed

2 files changed

+291
-0
lines changed

template/shlink/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## shlink - Self-Hosted URL Shortener
2+
3+
shlink is a powerful, self-hosted URL shortener built with PHP and designed to provide a modern, efficient solution for managing shortened URLs. It offers a robust set of features, including RESTful API support, multiple database compatibility, and extensive customization options. Whether you're running a small personal project or managing large-scale enterprise applications, shlink provides the tools necessary to create, track, and manage short URLs with ease.
4+
5+
### Key Features
6+
7+
- **Self-Hosted Solution**: Fully hostable on your own infrastructure, ensuring complete control over your data and privacy.
8+
- **RESTful API**: A comprehensive and well-documented API for seamless integration with external applications and services.
9+
- **Multiple Database Support**: Compatible with various database systems, including MySQL, PostgreSQL, and SQLite, offering flexibility in deployment.
10+
- **Customizable Short URLs**: Generate short URLs with custom slugs, allowing for branded and memorable links.
11+
- **Detailed Analytics**: Track and analyze click statistics, including geolocation, referrers, and user agents, to gain insights into link performance.
12+
- **QR Code Generation**: Automatically generate QR codes for any shortened URL, enhancing accessibility and usability.
13+
- **Authentication and Security**: Secure access to the application with API key authentication and role-based access control.
14+
- **CLI Tools**: Provides command-line utilities for managing URLs, tags, and other resources directly from the terminal.
15+
- **Extensible via Plugins**: Supports additional functionality through plugins, enabling further customization to meet specific needs.
16+
- **Docker Support**: Simplifies deployment with official Docker images, ensuring consistent environments across development and production.
17+
- **Open Source**: Released under an open-source license, encouraging community contributions and fostering transparency.
18+
19+
shlink is an ideal choice for developers and organizations seeking a reliable, feature-rich URL shortening solution that can be fully tailored to their requirements.
20+
21+
### Notice
22+
23+
1. Protect the login address: Set access restrictions to prevent unauthorized direct access.
24+
25+
2. Use a complex password: Create a password that includes uppercase letters, lowercase letters, numbers, and special characters to increase cracking difficulty.
26+
27+
3. Avoid common usernames: Refrain from using common usernames like "admin" or "root" to reduce the risk of brute-force attacks.
28+
29+
4. Regularly change passwords: It is recommended to update your password periodically to mitigate security risks associated with long-term usage of the same password.
30+
31+
5. Enable multi-factor authentication: Adopt two-factor authentication to add an extra layer of security beyond just the password.
32+
33+
6. Limit login attempts: Set a maximum number of failed login attempts, and temporarily lock the account once it is exceeded to prevent brute-force attacks.
34+
35+
7. Configure unusual login notifications: Set up alerts for abnormal login activity to be informed and respond promptly to potential security issues.
36+
37+
8. Conduct regular security audits: Periodically review account security logs and system configurations to quickly identify and fix potential vulnerabilities.
38+

template/shlink/index.yaml

Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
apiVersion: app.sealos.io/v1
2+
kind: Template
3+
metadata:
4+
name: shlink
5+
spec:
6+
title: 'Shlink'
7+
author: 'Sealos'
8+
date: 2025-05-14
9+
url: 'https://shlink.io/'
10+
gitRepo: 'https://github.com/shlinkio/shlink'
11+
description: 'A self-hosted URL shortener with QR code generation, analytics, and REST API.'
12+
readme: 'https://raw.githubusercontent.com/labring-actions/templates/main/template/shlink/README.md'
13+
icon: 'https://shlink.io/images/shlink-logo-blue.svg'
14+
templateType: inline
15+
locale: en
16+
categories:
17+
- web
18+
defaults:
19+
app_name:
20+
type: string
21+
value: shlink-${{ random(8) }}
22+
app_host:
23+
type: string
24+
value: ${{ random(8) }}
25+
inputs:
26+
initial_api_key:
27+
description: 'Initial API key'
28+
type: string
29+
default: ${{ random(8) }}
30+
required: false
31+
mail_from:
32+
description: 'Default "from" address for email notifications'
33+
type: string
34+
default: ''
35+
required: false
36+
geolite_license_key:
37+
description: 'GeoLite license key'
38+
type: string
39+
default: ''
40+
required: false
41+
---
42+
43+
apiVersion: v1
44+
kind: ServiceAccount
45+
metadata:
46+
labels:
47+
sealos-db-provider-cr: ${{ defaults.app_name }}-pg
48+
app.kubernetes.io/instance: ${{ defaults.app_name }}-pg
49+
app.kubernetes.io/managed-by: kbcli
50+
name: ${{ defaults.app_name }}-pg
51+
52+
---
53+
54+
apiVersion: apps/v1
55+
kind: Deployment
56+
metadata:
57+
name: ${{ defaults.app_name }}
58+
annotations:
59+
originImageName: ghcr.io/shlinkio/shlink:latest
60+
deploy.cloud.sealos.io/minReplicas: '1'
61+
deploy.cloud.sealos.io/maxReplicas: '1'
62+
labels:
63+
cloud.sealos.io/app-deploy-manager: ${{ defaults.app_name }}
64+
app: ${{ defaults.app_name }}
65+
spec:
66+
replicas: 1
67+
revisionHistoryLimit: 2
68+
selector:
69+
matchLabels:
70+
app: ${{ defaults.app_name }}
71+
template:
72+
metadata:
73+
labels:
74+
app: ${{ defaults.app_name }}
75+
spec:
76+
automountServiceAccountToken: false
77+
containers:
78+
- name: ${{ defaults.app_name }}
79+
image: ghcr.io/shlinkio/shlink:latest
80+
env:
81+
- name: INITIAL_API_KEY
82+
value: ${{ inputs.initial_api_key }}
83+
- name: PG_PASSWORD
84+
valueFrom:
85+
secretKeyRef:
86+
name: ${{ defaults.app_name }}-pg-conn-credential
87+
key: password
88+
- name: DB_DRIVER
89+
value: postgres
90+
- name: DB_NAME
91+
value: shlink
92+
- name: DB_USER
93+
value: postgres
94+
- name: DB_PASSWORD
95+
valueFrom:
96+
secretKeyRef:
97+
name: ${{ defaults.app_name }}-pg-conn-credential
98+
key: password
99+
- name: DB_HOST
100+
value: ${{ defaults.app_name }}-pg-postgresql.${{ SEALOS_NAMESPACE }}.svc
101+
- name: DB_PORT
102+
value: "5432"
103+
- name: DEFAULT_DOMAIN
104+
value: ${{ defaults.app_host }}.${{ SEALOS_CLOUD_DOMAIN }}
105+
- name: GEOIP_LICENSE_KEY
106+
value: ${{ inputs.geolite_license_key }}
107+
${{ if(inputs.mail_from !== '') }}
108+
- name: FROM_EMAIL
109+
value: ${{ inputs.mail_from }}
110+
${{ endif() }}
111+
ports:
112+
- containerPort: 8080
113+
resources:
114+
requests:
115+
cpu: 100m
116+
memory: 512Mi
117+
limits:
118+
cpu: 500m
119+
memory: 2Gi
120+
imagePullPolicy: IfNotPresent
121+
122+
---
123+
124+
apiVersion: v1
125+
kind: Service
126+
metadata:
127+
name: ${{ defaults.app_name }}
128+
labels:
129+
cloud.sealos.io/app-deploy-manager: ${{ defaults.app_name }}
130+
spec:
131+
ports:
132+
- port: 80
133+
targetPort: 8080
134+
selector:
135+
app: ${{ defaults.app_name }}
136+
137+
---
138+
139+
apiVersion: networking.k8s.io/v1
140+
kind: Ingress
141+
metadata:
142+
name: ${{ defaults.app_name }}
143+
labels:
144+
cloud.sealos.io/app-deploy-manager: ${{ defaults.app_name }}
145+
cloud.sealos.io/app-deploy-manager-domain: ${{ defaults.app_host }}
146+
annotations:
147+
kubernetes.io/ingress.class: nginx
148+
spec:
149+
rules:
150+
- host: ${{ defaults.app_host }}.${{ SEALOS_CLOUD_DOMAIN }}
151+
http:
152+
paths:
153+
- pathType: Prefix
154+
path: /
155+
backend:
156+
service:
157+
name: ${{ defaults.app_name }}
158+
port:
159+
number: 80
160+
tls:
161+
- hosts:
162+
- ${{ defaults.app_host }}.${{ SEALOS_CLOUD_DOMAIN }}
163+
secretName: ${{ SEALOS_CERT_SECRET_NAME }}
164+
165+
---
166+
167+
apiVersion: apps.kubeblocks.io/v1alpha1
168+
kind: Cluster
169+
metadata:
170+
finalizers:
171+
- cluster.kubeblocks.io/finalizer
172+
labels:
173+
clusterdefinition.kubeblocks.io/name: postgresql
174+
clusterversion.kubeblocks.io/name: postgresql-14.8.0
175+
sealos-db-provider-cr: ${{ defaults.app_name }}-pg
176+
annotations: {}
177+
name: ${{ defaults.app_name }}-pg
178+
spec:
179+
affinity:
180+
nodeLabels: {}
181+
podAntiAffinity: Preferred
182+
tenancy: SharedNode
183+
topologyKeys: []
184+
clusterDefinitionRef: postgresql
185+
clusterVersionRef: postgresql-14.8.0
186+
backup:
187+
enabled: true
188+
cronExpression: 0 18 * * *
189+
method: backupTool
190+
pitrEnabled: false
191+
retentionPeriod: 7d
192+
componentSpecs:
193+
- componentDefRef: postgresql
194+
monitor: true
195+
name: postgresql
196+
replicas: 1
197+
resources:
198+
limits:
199+
cpu: 500m
200+
memory: 512Mi
201+
requests:
202+
cpu: 50m
203+
memory: 128Mi
204+
serviceAccountName: ${{ defaults.app_name }}-pg
205+
switchPolicy:
206+
type: Noop
207+
volumeClaimTemplates:
208+
- name: data
209+
spec:
210+
accessModes:
211+
- ReadWriteOnce
212+
resources:
213+
requests:
214+
storage: 5Gi
215+
216+
terminationPolicy: Delete
217+
tolerations: []
218+
219+
---
220+
221+
apiVersion: rbac.authorization.k8s.io/v1
222+
kind: Role
223+
metadata:
224+
labels:
225+
sealos-db-provider-cr: ${{ defaults.app_name }}-pg
226+
app.kubernetes.io/instance: ${{ defaults.app_name }}-pg
227+
app.kubernetes.io/managed-by: kbcli
228+
name: ${{ defaults.app_name }}-pg
229+
rules:
230+
- apiGroups:
231+
- '*'
232+
resources:
233+
- '*'
234+
verbs:
235+
- '*'
236+
237+
---
238+
239+
apiVersion: rbac.authorization.k8s.io/v1
240+
kind: RoleBinding
241+
metadata:
242+
labels:
243+
sealos-db-provider-cr: ${{ defaults.app_name }}-pg
244+
app.kubernetes.io/instance: ${{ defaults.app_name }}-pg
245+
app.kubernetes.io/managed-by: kbcli
246+
name: ${{ defaults.app_name }}-pg
247+
roleRef:
248+
apiGroup: rbac.authorization.k8s.io
249+
kind: Role
250+
name: ${{ defaults.app_name }}-pg
251+
subjects:
252+
- kind: ServiceAccount
253+
name: ${{ defaults.app_name }}-pg

0 commit comments

Comments
 (0)