adding dockerfile and other files
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 56s
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 56s
This commit is contained in:
@@ -0,0 +1,42 @@
|
|||||||
|
name: Gitea Actions Demo
|
||||||
|
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "*"
|
||||||
|
paths:
|
||||||
|
- 'dockerfile'
|
||||||
|
tags-ignore:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Explore-Gitea-Actions:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
|
||||||
|
- name: List files in the repository
|
||||||
|
run: |
|
||||||
|
ls ${{ gitea.workspace }}
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Login to gitea
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: gitea.tryton.geeraert.eu
|
||||||
|
username: ${{ secrets.USERNAME_GITEA }}
|
||||||
|
password: ${{ secrets.PASSWORD_GITEA }}
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
tags: gitea.tryton.geeraert.eu/pi-ux-ce/geoip2-nginx:latest
|
||||||
|
cache-from: type=registry,ref=gitea.tryton.geeraert.eu/pi-ux-ce/geoip2-nginx:buildcache
|
||||||
|
cache-to: type=registry,ref=gitea.tryton.geeraert.eu/pi-ux-ce/geoip2-nginx:buildcache,mode=max
|
||||||
|
|
||||||
|
|
||||||
|
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||||
+43
@@ -0,0 +1,43 @@
|
|||||||
|
# Stage 1: Build the module
|
||||||
|
FROM nginx:1.26.3 AS builder
|
||||||
|
|
||||||
|
# Install build tools and MaxMind library
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y build-essential libmaxminddb-dev libpcre3-dev zlib1g-dev libssl-dev wget git && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
#https://nginx.org/download/nginx-1.26.3.tar.gz
|
||||||
|
# Download NGINX source matching the container version
|
||||||
|
RUN wget http://nginx.org/download/nginx-1.26.3.tar.gz && \
|
||||||
|
tar zxf nginx-1.26.3.tar.gz
|
||||||
|
|
||||||
|
# Clone the specific GeoIP2 module project
|
||||||
|
RUN git clone https://github.com/leev/ngx_http_geoip2_module.git
|
||||||
|
|
||||||
|
# Compile the module as a dynamic module
|
||||||
|
RUN cd nginx-${NGINX_VERSION} && \
|
||||||
|
./configure --with-compat --add-dynamic-module=../ngx_http_geoip2_module && \
|
||||||
|
make modules
|
||||||
|
|
||||||
|
# Stage 2: Final Image
|
||||||
|
FROM nginx:1.26.3
|
||||||
|
|
||||||
|
# Install only the runtime library
|
||||||
|
RUN apt-get update && apt-get install -y libmaxminddb0 && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Copy the compiled .so file from the builder
|
||||||
|
COPY --from=builder /nginx-1.26.3/objs/ngx_http_geoip2_module.so /usr/lib/nginx/modules/
|
||||||
|
|
||||||
|
# Copy your GeoIP database and NGINX config
|
||||||
|
# Ensure these files are in the same folder as this Dockerfile
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Copy your GeoLite2 database into the container
|
||||||
|
COPY ./data/dbip-country-lite-2026-01.mmdb /etc/nginx/geoip/GeoLite2-Country.mmdb
|
||||||
|
COPY ./data/dbip-country-lite-2026-01.mmdb /data/dbip-country-lite-2026-01.mmdb
|
||||||
|
|
||||||
|
# Copy your custom nginx config
|
||||||
|
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
+60
@@ -0,0 +1,60 @@
|
|||||||
|
#if the module doesn't load, search a similar path for this module and paste it there
|
||||||
|
# ls -l /usr/lib/nginx/modules/ngx_http_geoip2_module.so
|
||||||
|
|
||||||
|
load_module "/usr/lib/nginx/modules/ngx_http_geoip2_module.so";
|
||||||
|
#modules/ngx_http_geoip_module.so";
|
||||||
|
user nginx;
|
||||||
|
worker_processes auto;
|
||||||
|
|
||||||
|
error_log /var/log/nginx/error.log notice;
|
||||||
|
pid /run/nginx.pid;
|
||||||
|
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
http {
|
||||||
|
geoip2 /data/dbip-country-lite-2026-01.mmdb{
|
||||||
|
$geoip2_data_country_iso_code country iso_code;
|
||||||
|
$geoip2_data_city_name city names en;
|
||||||
|
$geoip2_data_country_name country names en;
|
||||||
|
}
|
||||||
|
|
||||||
|
map $geoip2_data_country_iso_code $allowed_country {
|
||||||
|
default yes;
|
||||||
|
IN no;
|
||||||
|
CN no; # Block China
|
||||||
|
RU no; # Block Russia
|
||||||
|
KP no; # Block North Korea
|
||||||
|
}
|
||||||
|
log_format main_ext '$remote_addr - $remote_user [$time_local] '
|
||||||
|
'"$request" $status $body_bytes_sent '
|
||||||
|
'"$http_referer" "$http_user_agent" '
|
||||||
|
'$geoip2_data_city_name $geoip2_data_country_name';
|
||||||
|
|
||||||
|
|
||||||
|
#code below coming from AI , not tested
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name yourdomain.com;
|
||||||
|
|
||||||
|
# 4. The actual block logic
|
||||||
|
if ($allowed_country = no) {
|
||||||
|
return 403; # Forbidden
|
||||||
|
# Or use 'return 444;' to close the connection without a response
|
||||||
|
# The 444 Status: If you want to save bandwidth and "ghost" attackers, use return 444;. It drops the connection immediately without even sending a "Forbidden" header.
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://your_backend;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user