Closed a-t-0 closed 1 year ago
nginx['ssl_client_certificate'] = "/etc/gitlab/ssl/ca.crt" nginx['ssl_certificate'] = "/etc/gitlab/ssl/public_certificate.crt" nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/private.key"
https://stackoverflow.com/questions/19979171/how-to-convert-pem-into-key
sudo cp ca.crt /etc/gitlab/ssl/ca.crt
openssl x509 -outform der -in cert.pem -out public_certificate.crt
sudo cp public_certificate.crt /etc/gitlab/ssl/public_certificate.crt
openssl rsa -outform der -in cert-key.pem -out private.key
sudo cp private.key /etc/gitlab/ssl/private.key
https://127.0.0.1:22 Nothing https://127.0.0.1:23 Nothing https://127.0.0.1:80 Nothing https://127.0.0.1:81 Nothing https://127.0.0.1:443 Nextcloud https://127.0.0.1:444 Nothing
https://localhost:22 Nothing https://localhost:23 Nothing https://localhost:80 Nothing https://localhost:81 Nothing https://localhost:443 Nextcloud https://localhost:444 Nothing
http://127.0.0.1:22 Nothing http://127.0.0.1:23 Nothing http://127.0.0.1:80 GitLab http://127.0.0.1:81 Nextcloud http://127.0.0.1:443 Bad request http://127.0.0.1:444 Nothing
http://localhost:22 Nothing http://localhost:23 Nothing http://localhost:80 GitLab http://localhost:81 Nextcloud http://localhost:443 Bad request http://localhost:444 Nothing
Bad Request Your browser sent a request that this server could not understand. Reason: You're speaking plain HTTP to an SSL-enabled server port. Instead use the HTTPS scheme to access this URL, please.
https://127.0.0.1:22 Nothing https://127.0.0.1:23 Nothing https://p7f3sxi4avnpwqwra63xhdb3rfrdd6axjm35ycptqudauqaf43vamsid.onion:80 Can't be reached https://127.0.0.1:81 Nothing https://p7f3sxi4avnpwqwra63xhdb3rfrdd6axjm35ycptqudauqaf43vamsid.onion:443 Cant provide secure connection https://127.0.0.1:444 Nothing
http://127.0.0.1:22 Nothing http://127.0.0.1:23 Nothing http://p7f3sxi4avnpwqwra63xhdb3rfrdd6axjm35ycptqudauqaf43vamsid.onion:80 Can't be reached http://127.0.0.1:81 Nothing http://p7f3sxi4avnpwqwra63xhdb3rfrdd6axjm35ycptqudauqaf43vamsid.onion:443 Cant provide secure connection http://127.0.0.1:444 Nothing
This site can’t provide a secure connectionp 7f3sxi4avnpwqwra63xhdb3rfrdd6axjm35ycptqudauqaf43vamsid.onion sent an invalid response. ERR_SSL_PROTOCOL_ERROR
Source: https://www.unixmen.com/how-to-install-and-configure-qemu-in-ubuntu/
sudo apt-get install qemu-kvm qemu virt-manager virt-viewer libvirt-bin
becomes:
sudo apt-get install qemu-kvm
Then create image with:
qemu-img create ubuntu.img 20G
Becomes:
cd ~/Downloads
qemu-img create ubuntu.img 20G
To boot the Virtual machine, run:
qemu-system-x86_64 -hda ubuntu.img -boot d -cdrom /home/sk/Soft_Backup/OS\ Images/New/ubuntu-15.04-server-amd64.iso -m 640
Becomes:
qemu-system-x86_64 -hda ubuntu.img -boot d -cdrom ~/Downloads/ubuntu-22.04.1-desktop-amd64.iso -m 640
or:
cd ~/Downloads
qemu-img create ubuntu21.img 20G
qemu-system-x86_64 --enable-kvm -m 1024 -machine smm=off -cdrom ~/Downloads/ubuntu-20.04.5-desktop-amd64.iso -boot order=d ubuntu21.img
Ubuntu 22.10:
cd ~/Downloads
qemu-img create ubuntu22.img 20G
qemu-system-x86_64 --enable-kvm -m 1024 -machine smm=off -cdrom ~/Downloads/ubuntu-22.04.1-desktop-amd64.iso -boot order=d ubuntu22.img
After installation, when QEMU asks, remove installation medium and press enter, close the QEMU and run:
qemu-system-x86_64 --enable-kvm -m 1024 -machine smm=off -boot order=d ubuntu22.img
Source: https://unix.stackexchange.com/a/239727 Works.
ctrl+left_alt+G
sudo apt update -y && sudo apt upgrade -y
The clean , updated image is: _clean.
Contains failed clean installation of GitLab.
Source add:
-smp 4
(I think to allocate 4 cpu recourses iso 1). Not sure if was actually faster or placebo.
Prerequisites on guest:
sudo apt install spice-vdagent
Preqequistites on host:
TODO
First line is to launch system, 2nd to 4th line are to enable copy paste with ctrl+c, ctrl+v.
qemu-system-x86_64 --enable-kvm -m 4096 -machine smm=off -boot order=d ubuntu22_clean1.img -smp 4
-chardev qemu-vdagent,id=ch1,name=vdagent,clipboard=on \
-device virtio-serial-pci \
-device virtserialport,chardev=ch1,id=ch1,name=com.redhat.spice.0
Allow copy paste in qemu:
qemu-system-x86_64 [ ... ] \
-chardev qemu-vdagent,id=ch1,name=vdagent,clipboard=on \
-device virtio-serial-pci \
-device virtserialport,chardev=ch1,id=ch1,name=com.redhat.spice.0
qemu-system-x86_64 --enable-kvm -m 4096 -machine smm=off -boot order=d ubuntu22_clean1.img -smp 4 \
-chardev qemu-vdagent,id=ch1,name=vdagent,clipboard=on \
-device virtio-serial-pci \
-device virtserialport,chardev=ch1,id=ch1,name=com.redhat.spice.0
Source: https://askubuntu.com/a/1378522
Without GitLab runner:
sudo apt install git -y
git clone https://github.com/TruCol/Self-host-GitLab-CI-for-GitHub.git
cd Sel*
git checkout separate-hub-lab
./install_gitlab.sh -s -le somegitlab@email.com -lp -lpre
With runner:
./install_gitlab -s -r -le somegitlab@email.com -lp -lpre
Run:
cd ~
git clone https://github.com/HiveMinds/Collabora-Online.git
cd Coll*
sudo apt install tor -y
Setting up ssl cert requires the tor domains to be created in /var/lib/tor/nextcloud/hostname
. (That seems to also require one to install nextcloud).
src/./main.sh -ct
cat tor_log.txt
If that says "Bind error cannot bind to 9050... tor already running?" then kill tor:
kill -9 `pidof tor`
and try again:
src/./main.sh -ct
That hangs, and then forcefully terminate it. Then run:
src/./main.sh -h
And it should recognise the tor domain at /var/tor/nextcloud...
That also gives quite a few errors, mainly because the script also tells Nextcloud to switch from http to https, even though nextcloud is not installed.
Then changing gitlab.rb and then copying the files and reconfiguring gitlab results in "letsencrypt does not give out cert for 127.0.0.1 (IP).
Solution:
First setup the self-hosted ssl certificates (for port 80) on a clean Ubuntu image, then install Gitlab, then verify you can visit gitlab at: https:127.0.0.1/80.
sudo apt install git -y
mkdir git
cd git
git clone https://github.com/TruCol/Self-host-GitLab-CI-for-GitHub.git
cd Sel*
git checkout https
./install_gitlab.sh -s -le somegitlab@email.com -lp -lpre
git clone https://github.com/HiveMinds/SSL4Tor.git
cd SSL4Tor
./src/main.sh \
--1-domain-1-service \
--delete-onion-domain \
--services 80:gitlab:443/22:ssh:22 \
--make-onion-domains \
--ssl-password somepassword \
--background-dash \
--make-ssl-certs \
--setup-ssh-server \
--get-onion-domain
First add root CA, and then reconfigure, then see if https://127.0.0.1:80 is available.
./src/main.sh -1d1s --services 80:gitlab:443 --apply-certs \
--convert-pem-to-crt-and-key \
--add-root-to-gitlab
Results: Check https://localhost:80 Check https://localhost:443 Check https://localhost:8050 on a new window in firefox for:
--services 80:gitlab:80/22:ssh:22 \
--services 80:gitlab:443/22:ssh:22 \ all 4 options fail (with/without gitlabSSLcertConversion, with/without adding rootca )
--services 80:gitlab:8050/22:ssh:22 \
--services 443:gitlab:80/22:ssh:22 \
--services 443:gitlab:443/22:ssh:22 \
--services 443:gitlab:8050/22:ssh:22 \
--services 8050:gitlab:80/22:ssh:22 \
--services 8050:gitlab:443/22:ssh:22 \
--services 8050:gitlab:8050/22:ssh:22 \
For those respective GitLab port settings, for various NGINX settings.
echo "nginx['enable'] = true" >>"$GITLAB_RB_TEMPLATE_DIR""gitlab.rb"
echo "nginx['redirect_http_to_https'] = true" >>"$GITLAB_RB_TEMPLATE_DIR""gitlab.rb"
echo "nginx['ssl_certificate'] = \"$ssl_public_key_in_gitlab_filepath\"" >>"$GITLAB_RB_TEMPLATE_DIR""gitlab.rb"
echo "nginx['ssl_certificate_key'] = \"$ssl_private_key_in_gitlab_filepath\"" >>"$GITLAB_RB_TEMPLATE_DIR""gitlab.rb"
#echo "nginx['ssl_dhparam'] = \"/etc/gitlab/ssl/dhparams.pem\"" >> "$GITLAB_RB_TEMPLATE_DIR""gitlab.rb"
echo "nginx['listen_port'] = 80" >>"$GITLAB_RB_TEMPLATE_DIR""gitlab.rb"
echo "nginx['listen_https'] = false" >>"$GITLAB_RB_TEMPLATE_DIR""gitlab.rb"
echo "nginx['ssl_client_certificate'] = \"/etc/gitlab/ssl/ca.crt\"" >>"$GITLAB_RB_TEMPLATE_DIR""gitlab.rb"
Youtube video above says: says: 05:29 sudo cat /etc/gitlab/gitlab.rb | grep external_url
Should return the external url.
Intermediate
openssl x509 -outform der -in your-cert.pem -out your-cert.crt
openssl pkey -in cert.pem -out cert.key
Step 3
Create /etc/gitlab/ssl directory.
Because that is where it looks for these files.
You can verify GitLab looks at this directory becuase the /etc/gitlab/gitlab.rb
file should contain:
The name of the .key and .crt files should be that of the ("FULLY QUALIFIED DOMAIN NAME") = localhost or 127.0.0.1 or asdflaksjdfasdflkj.onion
So output the .key
and .crt
files to either:
/etc/gitlab/ssl/localhost.key
/etc/gitlab/ssl/localhost.crt
or
/etc/gitlab/ssl/127.0.0.1.key
/etc/gitlab/ssl/127.0.0.1.crt
or
/etc/gitlab/ssl/some_long_onion.onion.key
/etc/gitlab/ssl/some_long_onion.onion.crt
07:58:
sudo mkdir -p /etc/gitlab/ssl
sudo chmod 755 /etc/gitlab/ssl
sudo cp your_cert.crt /etc/gitlab/ssl/
sudo gitlab-ctl reconfigure
Below is the code I used to successfully run a self-hosted instance of GitLab over https://localhost:443 using self-signed SSL certificates:
The GitLab instance can be installed with:
sudo apt install git -y
mkdir git
cd git
git clone https://github.com/TruCol/Self-host-GitLab-CI-for-GitHub.git
cd Sel*
git checkout https
./install_gitlab.sh \
--server \
--gitlab-email somegitlab@email.com \
--gitlab-password \
--labprereq \
--external-url "https://0.0.0.0" \
--gitlab-server "0.0.0.0"
The self-signed SSL certificates for the onion domains (and localhost) for GitLab can be created with:
git clone https://github.com/HiveMinds/SSL4Tor.git
cd SSL4Tor
./src/main.sh \
--1-domain-1-service \
--delete-onion-domain \
--services 443:gitlab:443/22:ssh:22 \
--make-onion-domains \
--ssl-password somepassword \
--background-dash \
--make-ssl-certs \
--setup-ssh-server \
--get-onion-domain
Next, those SSL-certificates can be automatically added to GitLab, and GitLab is automatically reconfigured with:
./src/main.sh -1d1s --services 80:gitlab:443 --apply-certs
Next, one should be able to visit GitLab at https://localhost:443
To make this work,
GitLab.rb
as described below.https://www.youtube.com/watch?v=2XE6axvWXSU
In
~/gitlab//config/GitLab.rb
changeto:
or:
Create dir:
gitlab-ctl reconfigure.