diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..da7194b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,61 @@ +--- +name: Publish Docker image + +on: + release: + types: [published] + +jobs: + release: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Setup mirror + uses: self-actuated/hub-mirror@master + + - name: Get TAG + id: get_tag + run: echo TAG=${GITHUB_REF##*/} >> $GITHUB_ENV + + - name: Get Repo Owner + id: get_repo_owner + run: echo "REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" > $GITHUB_ENV + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: "Get docker info" + run: | + echo "Actor: ${{ github.actor }}" + + - name: "Log into GitHub Container Registry" + if: "github.event_name != 'pull_request'" + uses: "docker/login-action@v1" + with: + registry: "ghcr.io" + username: "${{ github.actor }}" + password: "${{ secrets.GITHUB_TOKEN }}" + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + platforms: linux/amd64,linux/arm64 + build-args: | + VERSION=${{ env.TAG }} + GitCommit=${{ github.sha }} + context: . + push: true + tags: | + ghcr.io/${{ env.REPO_OWNER }}/squid:${{ github.sha }} + ghcr.io/${{ env.REPO_OWNER }}/squid:${{ env.TAG }} + ghcr.io/${{ env.REPO_OWNER }}/squid:latest + labels: | + LABEL org.opencontainers.image.source="https://github.com/${{ env.REPO_OWNER }}/squid" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..74f70c8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM centos:7 + +RUN yum -y install squid openssl +COPY squid.conf.template /etc/squid/squid.conf.template +COPY myCA.pem /etc/squid/ssl_cert/myCA.pem +COPY entrypoint.sh /entrypoint.sh +RUN chmod 755 /entrypoint.sh && yum clean all + +CMD ["/entrypoint.sh"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..522f813 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Squid with SSL support + +A simple squid container with SSL support (ssl_bump) enabled by default +plus a helm chart to install it into Kubernetes. + diff --git a/charts/squid/.helmignore b/charts/squid/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/squid/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/squid/Chart.yaml b/charts/squid/Chart.yaml new file mode 100644 index 0000000..91c7ce0 --- /dev/null +++ b/charts/squid/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: squid +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/charts/squid/templates/NOTES.txt b/charts/squid/templates/NOTES.txt new file mode 100644 index 0000000..a7483d0 --- /dev/null +++ b/charts/squid/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "squid.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "squid.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "squid.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "squid.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/charts/squid/templates/_helpers.tpl b/charts/squid/templates/_helpers.tpl new file mode 100644 index 0000000..2087785 --- /dev/null +++ b/charts/squid/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "squid.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "squid.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "squid.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "squid.labels" -}} +helm.sh/chart: {{ include "squid.chart" . }} +{{ include "squid.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "squid.selectorLabels" -}} +app.kubernetes.io/name: {{ include "squid.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "squid.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "squid.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/squid/templates/configmap.yaml b/charts/squid/templates/configmap.yaml new file mode 100644 index 0000000..1a51ab7 --- /dev/null +++ b/charts/squid/templates/configmap.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "squid.fullname" . }}-conf + labels: + app: {{ template "squid.name" . }} + chart: {{ template "squid.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + squid.conf: | +{{- if .Values.metrics.enabled }} + acl prometheus src 127.0.0.1/32 + http_access allow manager prometheus +{{- end }} +{{ .Values.config | indent 4 }} \ No newline at end of file diff --git a/charts/squid/templates/deployment.yaml b/charts/squid/templates/deployment.yaml new file mode 100644 index 0000000..42fe461 --- /dev/null +++ b/charts/squid/templates/deployment.yaml @@ -0,0 +1,151 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "squid.fullname" . }} + labels: + app: {{ template "squid.name" . }} + chart: {{ template "squid.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "squid.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "squid.name" . }} + release: {{ .Release.Name }} + annotations: + checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} + spec: +{{- if .Values.image.imagePullSecrets }} + imagePullSecrets: + - name: {{ .Values.image.imagePullSecrets }} +{{- end }} + initContainers: + # if there is a line in config map that starts with `cache_dir` + # run `squid -z` which will create the cache structure on the filesystem + - name: create-cache-dir + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + resources: +{{ toYaml .Values.resources | indent 12 }} + volumeMounts: + - name: {{ template "squid.fullname" . }}-conf + mountPath: /etc/squid/squid.conf + subPath: squid.conf + - name: cache + mountPath: /var/cache/squid + {{- if .Values.configSecret }} + - name: config-secret + mountPath: /etc/squid/config + {{- end }} + command: + - /bin/sh + - -c + args: +{{ toYaml .Values.initContainersArgs | indent 12 }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 3128 + protocol: TCP + - name: https + containerPort: 3129 + protocol: TCP + volumeMounts: + - name: {{ template "squid.fullname" . }}-conf + mountPath: /etc/squid/squid.conf + subPath: squid.conf + - name: cache + mountPath: /var/cache/squid + {{- if .Values.configSecret }} + - name: config-secret + mountPath: /etc/squid/config + {{- end }} + # Load the configuration files for nginx + livenessProbe: + tcpSocket: + port: 3128 + initialDelaySeconds: 5 + periodSeconds: 10 + readinessProbe: + tcpSocket: + port: 3128 + initialDelaySeconds: 5 + periodSeconds: 10 + resources: +{{ toYaml .Values.resources | indent 12 }} +{{- if .Values.metrics.enabled }} + - name: exporter + image: "{{ .Values.metrics.exporter.image.repository }}:{{ .Values.metrics.exporter.image.tag }}" + imagePullPolicy: {{ .Values.metrics.exporter.image.pullPolicy }} + env: + - name: SQUID_HOSTNAME + value: {{ .Values.hostname | default "localhost" | quote }} + - name: SQUID_EXPORTER_LISTEN + value: ":{{ .Values.metrics.exporter.port }}" + - name: SQUID_PORT + value: "3128" + ports: + - name: metrics + containerPort: {{ .Values.metrics.exporter.port }} + protocol: TCP + livenessProbe: + tcpSocket: + port: {{ .Values.metrics.exporter.port }} + initialDelaySeconds: 5 + periodSeconds: 10 + readinessProbe: + httpGet: + path: /metrics + port: metrics + initialDelaySeconds: 5 + periodSeconds: 10 + resources: +{{ toYaml .Values.metrics.exporter.resources | indent 12 }} +{{- end }} + volumes: + - name: {{ template "squid.fullname" . }}-conf + configMap: + name: {{ template "squid.fullname" . }}-conf + - emptyDir: {} + name: cache + {{- if .Values.configSecret }} + - name: config-secret + secret: + secretName: {{ .Values.configSecret }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} + {{- if or .Values.releaseAntiAffinity .Values.affinity }} + affinity: + {{- end }} + {{- if .Values.releaseAntiAffinity }} + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + topologyKey: kubernetes.io/hostname + labelSelector: + matchExpressions: + - key: release + operator: In + values: + - {{ .Release.Name }} + {{- end }} + {{- with .Values.affinity }} +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} diff --git a/charts/squid/templates/hpa.yaml b/charts/squid/templates/hpa.yaml new file mode 100644 index 0000000..10945fe --- /dev/null +++ b/charts/squid/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "squid.fullname" . }} + labels: + {{- include "squid.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "squid.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/squid/templates/ingress.yaml b/charts/squid/templates/ingress.yaml new file mode 100644 index 0000000..a7983bc --- /dev/null +++ b/charts/squid/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "squid.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "squid.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/squid/templates/service.yaml b/charts/squid/templates/service.yaml new file mode 100644 index 0000000..8b92f07 --- /dev/null +++ b/charts/squid/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "squid.fullname" . }} + labels: + {{- include "squid.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "squid.selectorLabels" . | nindent 4 }} diff --git a/charts/squid/templates/serviceaccount.yaml b/charts/squid/templates/serviceaccount.yaml new file mode 100644 index 0000000..2912e2b --- /dev/null +++ b/charts/squid/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "squid.serviceAccountName" . }} + labels: + {{- include "squid.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/squid/templates/tests/test-connection.yaml b/charts/squid/templates/tests/test-connection.yaml new file mode 100644 index 0000000..12ad61f --- /dev/null +++ b/charts/squid/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "squid.fullname" . }}-test-connection" + labels: + {{- include "squid.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "squid.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/charts/squid/values.yaml b/charts/squid/values.yaml new file mode 100644 index 0000000..5bdbdd5 --- /dev/null +++ b/charts/squid/values.yaml @@ -0,0 +1,138 @@ +replicaCount: 1 + +apiVersionOverrides: {} +## Override ingress api auto detection: +# ingress: networking.k8s.io/v1 + +image: + repository: ghcr.io/digitalis-io/squid + tag: latest + pullPolicy: IfNotPresent + # imagePullSecrets: + +hostname: localhost + +initContainersArgs: + - |- + set -e + chown -R squid.squid /var/cache/squid + chmod 770 /var/cache/squid + squid -z --foreground 2>&1 + +service: + type: ClusterIP + # Specify IP to whitelist if needed + #loadBalancerSourceRanges: "" + # Specify external IP if needed + #loadBalancerIP: "" + port: 80 + # annotations: {} + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + path: / + pathType: Prefix + hosts: + - chart-example.local + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +config: | + acl SSL_ports port 443 + acl Safe_ports port 80 # http + acl Safe_ports port 21 # ftp + acl Safe_ports port 443 # https + acl Safe_ports port 70 # gopher + acl Safe_ports port 210 # wais + acl Safe_ports port 1025-65535 # unregistered ports + acl Safe_ports port 280 # http-mgmt + acl Safe_ports port 488 # gss-http + acl Safe_ports port 591 # filemaker + acl Safe_ports port 777 # multiling http + acl CONNECT method CONNECT + + # Recommended minimum Access Permission configuration: + # + # Deny requests to certain unsafe ports + http_access deny !Safe_ports + + # Only allow cachemgr access from localhost + http_access allow localhost manager + http_access deny manager + + # Squid normally listens to port 3128 + http_port 3128 + + # Uncomment and adjust the following to add a disk cache directory. + #cache_dir ufs /var/cache/squid 100 16 256 + + # Leave coredumps in the first cache dir + coredump_dir /var/cache/squid + + # + # Add any of your own refresh_pattern entries above these. + # + refresh_pattern ^ftp: 1440 20% 10080 + refresh_pattern ^gopher: 1440 0% 1440 + refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 + refresh_pattern . 0 20% 4320 + + # Do not display squid version + httpd_suppress_version_string on + +# Optionally specify a secret whose contents will be mounted into /etc/squid/config. +# configSecret: config-example + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +releaseAntiAffinity: true + +metrics: + enabled: false + serviceMonitor: false + exporter: + port: 9301 + resources: {} + image: + repository: boynux/squid-exporter + tag: v1.9 + pullPolicy: IfNotPresent diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..a6557a9 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,10 @@ +#!/bin/bash -x + +cp /etc/squid/squid.conf.template /etc/squid/squid.conf + +ssl_crtd=$(find /usr -type f -name ssl_crtd) +$ssl_crtd -c -s /var/lib/ssl_db +chown -R squid:squid /var/lib/ssl_db + +/usr/sbin/squid -N -f /etc/squid/squid.conf -z +/usr/sbin/squid -NYCd 1 -f /etc/squid/squid.conf diff --git a/myCA.pem b/myCA.pem new file mode 100644 index 0000000..5cd242f --- /dev/null +++ b/myCA.pem @@ -0,0 +1,51 @@ +-----BEGIN PRIVATE KEY----- +MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDVhiiuvfMBpdLJ +BS/R2iFaLaDCAMzgTyHbps2x/H2lhUzrIrP4xTrOx8vOmBtzi/nA7xDkqq7lXR1p +0YpGM9jfRwOaD9y68c63ABd3yK5BVBFSgATIzKuC0SqHarYBwTlnUG5eRQlsUVQ6 +QK8b+EWd79dhNyRvHKOClGR7tL2xjEqEJ1d8bczxfvyqsuyW1jKsofUm4qbV+B8X +xYlRY+goJwGoRgB5NTO9Z16HCUfMWla2uAjP4MvaNj7srfgFuPatxjO6RicjhOIz +XO1atqNp/Rf3DER9tPlowZ3Qi86uOMrvu/sbBPGWEpv4Rq3yR8zS3cn0oBkEp7Po +XefBlD43AgMBAAECggEAT1B+XCqC0eHe4nzivnjgWrcIOAhEEi5SzVywm6TGp21U +nSNO5uGcbqMYua0WxV0BcQFcrRQZ02k7O8tyKZGoxYeDdv7dZzPbLW8DSKNq1yl7 +JcIYBN7B9t3rhlHFOfGkeRQPa0UJswqi1uCgKyuV8Ize3GW3Su7AbgjhKnKA5Coi +bt9ZhdfSGbQLAJmOdDJs5pu6aiU2kWo5swvf3PzhAgyxWCDy6wAtuFxiRMwYQc/A +WtZr/xfd6KWEs45IwaoAFv2/PswEo7egkrtc7QgfQba2eHHq25bI8JiUGiCk9zRY +N+P5vyEhK19b0GAOFRjMf8k9NKdtX4VCKmPId2ZmAQKBgQD8eEzc+ZjQbancxT+L +bZmYjEpfFEMpK2GKHL4igby187N8JCrsN34+el9xMuYSftVtgw666fQnbJsoAPTG +o99dwvzjHI/tLDLUIypyY2AIX6/PkFPhwOq0uE8dp9hk4CqJ0zC/qAXm5ULaRRvs +BWEJsBKH5udAfdfWK6hPktvLlwKBgQDYgnRX9tRl6SQ9NT1hL0jfhUnc2Km/N1M/ +SIkuBBlLSUFDAS3kQzJICaJF/JP4VRcvltxMPeGRqY19H9nfhtZMRDyWj/b37cTt +kLPfPfPLencXnbxOEX0+eGcChzXSClx/vfDBxKdgtK0FQc58YcQrR5Tb8elILMST +SbqHJ7/2YQKBgQDi4f05C/jfPd3Lb1s2omzIoTJolV3xjnGeW0wm2G5NGU9vvVTx +aMFDxlck9De74U1Nl9xR7tMh5sDcR1exdyzRJtx6AH37BqA68ctAdrujatIk9q/b +DbIebA91OBQIO0cfCrIhWg7Lu7XDTx3TkdXtjdRpWwDwfObNKficYf6xywKBgQC3 +VoC+nD1vruUJD7RSP4AuBuhtIutbCLZtuDaxyLbCkd25p5381QoXBlFrgl6qwyNH +ITCbPytr9W/irL4KElwVaRMFTBOODsHbidVHDWcMvz9puCBk21p7M+nGskhY/H0n +juf4rVYvBdAdy4PWv9Ml8w+S0F8CxyYOszhIith7AQKBgQCgIhuZoXQQI0E7xq4C +NyNxAcHfl8sVdONKVco2JLScyy9yo5ED50tTBxV0fMaS+c60+Mstzh2CCw7Ho7Y7 +b8mre2muDwggqALLmK+83KLS0aXJIX6l3frUqW0HSMkJCGLCftjv4pr3GHZ3QGfO +XAaGtxdQyXCTibQ+PmBFLPbqng== +-----END PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIIDzTCCArWgAwIBAgIUUNtNZXV3x9y6ScflqAPLZoPkl4gwDQYJKoZIhvcNAQEL +BQAwdjELMAkGA1UEBhMCR0IxDzANBgNVBAgMBkxvbmRvbjEPMA0GA1UEBwwGTG9u +ZG9uMRgwFgYDVQQKDA9NeSBDb29sIENvbXBhbnkxDzANBgNVBAsMBkRldk9wczEa +MBgGA1UEAwwRc3F1aWQuZXhhbXBsZS5jb20wHhcNMjMwOTE4MTAwMDQyWhcNMzMw +OTE1MTAwMDQyWjB2MQswCQYDVQQGEwJHQjEPMA0GA1UECAwGTG9uZG9uMQ8wDQYD +VQQHDAZMb25kb24xGDAWBgNVBAoMD015IENvb2wgQ29tcGFueTEPMA0GA1UECwwG +RGV2T3BzMRowGAYDVQQDDBFzcXVpZC5leGFtcGxlLmNvbTCCASIwDQYJKoZIhvcN +AQEBBQADggEPADCCAQoCggEBANWGKK698wGl0skFL9HaIVotoMIAzOBPIdumzbH8 +faWFTOsis/jFOs7Hy86YG3OL+cDvEOSqruVdHWnRikYz2N9HA5oP3LrxzrcAF3fI +rkFUEVKABMjMq4LRKodqtgHBOWdQbl5FCWxRVDpArxv4RZ3v12E3JG8co4KUZHu0 +vbGMSoQnV3xtzPF+/Kqy7JbWMqyh9SbiptX4HxfFiVFj6CgnAahGAHk1M71nXocJ +R8xaVra4CM/gy9o2Puyt+AW49q3GM7pGJyOE4jNc7Vq2o2n9F/cMRH20+WjBndCL +zq44yu+7+xsE8ZYSm/hGrfJHzNLdyfSgGQSns+hd58GUPjcCAwEAAaNTMFEwHQYD +VR0OBBYEFJFlVBNzQrvaKHVrwbk0Q2FLgo95MB8GA1UdIwQYMBaAFJFlVBNzQrva +KHVrwbk0Q2FLgo95MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEB +ALHR5Z0x/CFk6LKRFR4dBhquWai7dLWH+9cxNSvGt7x85rsZIyAJ8UwPVl00e2IT +IR/0Av86QOvImec295jd2EgbCZ3AmFvEz4U8liRmwOQZvc+W8COTc+yF7z3sTWbR +C9I/uZPrDOHCWIoBcbUQ16d8my9gZBZWZ4oBp2ogDtxb48se76NEu42R/swdQnvS +rEFbcHvpFytZt7W7oOwpfbOElN+UGtZ1v7fU8PKflALWXYJmeV30zQeoxb3HOk4A +71u+DaTr6Z9qH9av63o4s3LHXqaUNtJe3MQLF1bC6g+tb2NDygrb7ZbnLTSi/ol1 +n6TFGP12eTRiXmvQrjTT0Ds= +-----END CERTIFICATE----- diff --git a/squid.conf.template b/squid.conf.template new file mode 100644 index 0000000..2f5281f --- /dev/null +++ b/squid.conf.template @@ -0,0 +1,43 @@ +acl localnet src 10.0.0.0/8 # RFC1918 possible internal network +acl localnet src 172.16.0.0/12 # RFC1918 possible internal network +acl localnet src 192.168.0.0/16 # RFC1918 possible internal network +acl localnet src fc00::/7 # RFC 4193 local private network range +acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines + +acl SSL_ports port 443 +acl Safe_ports port 80 # http +acl Safe_ports port 21 # ftp +acl Safe_ports port 443 # https +acl Safe_ports port 70 # gopher +acl Safe_ports port 210 # wais +acl Safe_ports port 1025-65535 # unregistered ports +acl Safe_ports port 280 # http-mgmt +acl Safe_ports port 488 # gss-http +acl Safe_ports port 591 # filemaker +acl Safe_ports port 777 # multiling http +acl CONNECT method CONNECT + +http_access deny !Safe_ports + +http_access deny CONNECT !SSL_ports + +http_access allow localhost manager +http_access deny manager + + +http_access allow localnet +http_access allow localhost + +http_access deny all + +http_port 3120 intercept +https_port 3129 intercept ssl-bump generate-host-certificates=on dynamic_cert_mem_cache_size=16MB cert=/etc/squid/ssl_cert/myCA.pem +http_port 3128 ssl-bump generate-host-certificates=on dynamic_cert_mem_cache_size=16MB cert=/etc/squid/ssl_cert/myCA.pem + + +coredump_dir /var/spool/squid + +refresh_pattern ^ftp: 1440 20% 10080 +refresh_pattern ^gopher: 1440 0% 1440 +refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 +refresh_pattern . 0 20% 4320