Skip to content

Instantly share code, notes, and snippets.

@quangthe
quangthe / SSL-nginx-Docker.md
Created April 2, 2022 10:11 — forked from dahlsailrunner/SSL-nginx-Docker.md
SSL with Docker images using nginx as reverse proxy

Docker with SSL and an nginx reverse proxy

Running your ASP.NET Core (or other) application in Docker using SSL should not be an overwhelming task. These steps should do the trick.

Run the following steps from a Linux terminal (I used WSL or WSL2 on Windows from the Windows Terminal).

1. Create a conf file with information about the cert you'll be creating

It should look something like the content below; call it my-site.conf or something like that.

@quangthe
quangthe / server.conf
Last active April 3, 2022 14:32 — forked from timcheadle/server.conf
SSL nginx config example
server {
listen 80;
server_name www.example.com example.com;
# Redirect all traffic to SSL
rewrite ^ https://$server_name$request_uri? permanent;
}
server {
listen 443 ssl default_server;
@quangthe
quangthe / Jenkinsfile
Last active April 3, 2022 14:40 — forked from bcomnes/Jenkinsfile
Jenkinsfile stuff, Jenkins 101
/*
Git env vars you might need in jenkins
Jenkins ENV Reference:
env.GIT_COMMIT: the commit sha of the current build
env.BRANCH_NAME: the branch name OR tag name of the current build, when it exists
env.GIT_BRANCH: same as BRANCH_NAME
env.TAG_NAME: the tag name of the current build, when it exists
*/
// stash and unstash
@quangthe
quangthe / minikube-docker.md
Last active August 21, 2023 07:23
Docker with Minikube (Replace Docker Desktop)

Installation

brew install minikube

# install docker cli only
brew install docker

brew install docker-compose
@quangthe
quangthe / lima.md
Last active April 7, 2022 03:35
Lima: Docker Desktop replacement

Install lima

brew install lima

2022-02-07: nerdctl is not supported for MacOS. Cannot install via brew install nerdctl

With Docker

Set alias in .bashrc or .zshrc

alias docker="lima nerdctl"

@quangthe
quangthe / rsa_util.go
Created December 2, 2021 10:53 — forked from miguelmota/rsa_util.go
Golang RSA encrypt and decrypt example
package ciphers
import (
"crypto/rand"
"crypto/rsa"
"crypto/sha512"
"crypto/x509"
"encoding/pem"
"log"
)
@quangthe
quangthe / jaas.config
Created November 25, 2021 11:21 — forked from serpensalbus/jaas.config
JAAS config Magnolia example configuration file
/**
* options for JCRAuthenticationModule module:
* realm: to restrict the login to a certain realm
* use_realm_callback: to allow the GUI to pass the realm to login into
* skip_on_previous_success: if true the login is scipped if a former module proceeded a successfull login
*
* example:
* info.magnolia.jaas.sp.jcr.JCRAuthenticationModule requisite realm=public;
* info.magnolia.jaas.sp.jcr.JCRAuthenticationModule requisite realm=admin skip_on_previous_success=true;
*/
@quangthe
quangthe / create_image_pull_secret.sh
Created October 14, 2021 07:18
Create Gitlab image pull secret
# Create image pull secret
kubectl delete secret gitlab-registry-creds --ignore-not-found
kubectl create secret docker-registry gitlab-registry-creds \
--docker-server=https://${CI_REGISTRY} \
--docker-username=${CI_DEPLOY_USER} \
--docker-password=${CI_DEPLOY_PASSWORD}
@quangthe
quangthe / main.go
Created October 12, 2021 03:44
Go error handling
import (
"fmt"
"errors"
tce "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
)
// Way 1
if _, ok := err.(*tce.TencentCloudSDKError); ok {
return fmt.Errorf("An API error has returned: %s", err)