Added self signed certificate for rocky linux and rocky config. Also added mariadb-latest install

This commit is contained in:
Eliezer Croitoru 2024-11-21 01:30:10 +02:00
parent df714ffef9
commit 756e878bc1
6 changed files with 162 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
cert.pem
key.pem
gitea-linux-amd64
mariadb_repo_setup

View File

@ -16,6 +16,9 @@ install-dependencies-rocky:
dnf -y install mariadb-server dnf -y install mariadb-server
git --version git --version
install-latest-mariadb-rocky:
bash install-latest-mariadb-rocky.sh
enable-mariadb: enable-mariadb:
systemctl daemon-reload systemctl daemon-reload
systemctl enable mariadb systemctl enable mariadb
@ -23,6 +26,9 @@ enable-mariadb:
start-mariadb: start-mariadb:
systemctl start mariadb systemctl start mariadb
prepare-db:
mysql < prepare-gitea-db.sql
enable-nginx: enable-nginx:
systemctl daemon-reload systemctl daemon-reload
systemctl enable nginx systemctl enable nginx
@ -30,6 +36,18 @@ enable-nginx:
start-nginx: start-nginx:
systemctl start nginx systemctl start nginx
stop-nginx:
systemctl stop nginx
restart-nginx: stop-nginx start-nginx
enable-gitea:
systemctl daemon-reload
systemctl enable gitea
start-gitea:
systemctl start gitea
create-user-debian: create-user-debian:
adduser --system --shell /bin/bash --gecos 'Git Version Control' \ adduser --system --shell /bin/bash --gecos 'Git Version Control' \
--group --disabled-password --home /home/git git --group --disabled-password --home /home/git git
@ -93,4 +111,11 @@ install-nginx-debian:
install-nginx-rocky: install-nginx-rocky:
dnf -y install nginx dnf -y install nginx
create-nginx-ssl-dir:
mkdir -pv /etc/ssl/nginx
generate-self-signed-certificate:
bash gen-self-signed-cert.sh
install-nginx-conf-rocky:
cp -vf rocky-nginx.conf /etc/nginx/nginx.conf

8
gen-self-signed-cert.sh Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
openssl req -newkey rsa:4096 -nodes -keyout \
key.pem -x509 -sha256 -days 3650 -subj "/C=IL/ST=CE/L=Center/O=NgTech LTD/OU=IT/CN=gitea.ngtech.home" \
-addext "subjectAltName = DNS:*.ngtech.home, DNS:localhost, DNS:127.0.0.1" -out cert.pem
cp -vf key.pem /etc/ssl/nginx/key.pem
cp -vf cert.pem /etc/ssl/nginx/cert.pem

13
install-latest-mariadb-rocky.sh Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -e
set -x
wget "https://r.mariadb.com/downloads/mariadb_repo_setup" -O "mariadb_repo_setup"
bash mariadb_repo_setup
dnf remove mariadb-gssapi-server -y
dnf install MariaDB-server -y
set +e
set +x

6
prepare-gitea-db.sql Normal file
View File

@ -0,0 +1,6 @@
CREATE DATABASE giteadb CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_bin';
CREATE USER 'gitea'@'%' IDENTIFIED BY 'gitea';
GRANT ALL PRIVILEGES ON giteadb.* TO 'gitea';
FLUSH PRIVILEGES;

106
rocky-nginx.conf Normal file
View File

@ -0,0 +1,106 @@
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 4096;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
listen [::]:80;
server_name _;
root /usr/share/nginx/html;
location / {
client_max_body_size 8192M;
proxy_pass http://localhost:3000;
proxy_set_header Connection $http_connection;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
# Settings for a TLS enabled server.
#
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name _;
root /usr/share/nginx/html;
ssl_certificate "/etc/ssl/nginx/cert.pem";
ssl_certificate_key "/etc/ssl/nginx/key.pem";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers PROFILE=SYSTEM;
ssl_prefer_server_ciphers on;
location / {
client_max_body_size 8192M;
proxy_pass http://localhost:3000;
proxy_set_header Connection $http_connection;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
#
# # Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
#
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}