Skip to content

Commit e5950a4

Browse files
committed
init
0 parents  commit e5950a4

File tree

8 files changed

+229
-0
lines changed

8 files changed

+229
-0
lines changed

.dockerignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Ignore version control files
2+
.git
3+
.gitignore
4+
.github
5+
6+
# Ignore documentation and metadata files
7+
LICENSE
8+
*.md
9+
10+
# Ignore environment files
11+
.env
12+
.env.*
13+
14+
# Ignore Node.js modules
15+
node_modules
16+
npm-debug.log
17+
18+
# Ignore temporary and cache files
19+
tmp/
20+
cache/
21+
22+
# Ignore build artifacts and archives
23+
*.tar
24+
*.zip
25+
26+
# Ignore Docker Compose files
27+
docker-compose.yml
28+
docker-compose*.yaml

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text eol=lf
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Docker Publish
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
push_to_registries:
9+
name: Push Docker image to Docker Hub and GHCR
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
packages: write
14+
attestations: write
15+
id-token: write
16+
17+
steps:
18+
- name: Check out the repo
19+
uses: actions/checkout@v4
20+
21+
- name: Log in to Docker Hub
22+
uses: docker/login-action@v3
23+
with:
24+
registry: docker.io
25+
username: ${{ secrets.DOCKER_USERNAME }}
26+
password: ${{ secrets.DOCKER_PASSWORD }}
27+
28+
- name: Log in to GitHub Container Registry (GHCR)
29+
uses: docker/login-action@v3
30+
with:
31+
registry: ghcr.io
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GH_TOKEN }}
34+
35+
- name: Extract metadata (tags, labels) for Docker
36+
id: meta
37+
uses: docker/metadata-action@v5
38+
with:
39+
images: |
40+
docker.io/infocyph/nginx
41+
ghcr.io/infocyph/nginx
42+
43+
- name: Build and push Docker images
44+
id: push
45+
uses: docker/build-push-action@v6
46+
with:
47+
context: .
48+
push: true
49+
tags: ${{ steps.meta.outputs.tags }}
50+
labels: ${{ steps.meta.outputs.labels }}
51+
52+
- name: Generate artifact attestation for Docker Hub
53+
uses: actions/attest-build-provenance@v2
54+
with:
55+
subject-name: docker.io/infocyph/nginx
56+
subject-digest: ${{ steps.push.outputs.digest }}
57+
push-to-registry: true
58+
github-token: ${{ secrets.GH_TOKEN }}
59+
60+
- name: Generate artifact attestation for GHCR
61+
uses: actions/attest-build-provenance@v2
62+
with:
63+
subject-name: ghcr.io/infocyph/nginx
64+
subject-digest: ${{ steps.push.outputs.digest }}
65+
push-to-registry: true
66+
github-token: ${{ secrets.GH_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea
2+
*~

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM nginx:mainline-alpine
2+
LABEL org.opencontainers.image.source="https://github.com/infocyph/docker-nginx"
3+
LABEL org.opencontainers.image.description="NGINX with updated params"
4+
LABEL org.opencontainers.image.licenses="MIT"
5+
LABEL org.opencontainers.image.authors="infocyph,abmmhasan"
6+
RUN apk add --no-cache bash
7+
COPY scripts/fcgi-params.sh /usr/local/bin/fcgi_params.sh
8+
COPY scripts/proxy-params.sh /usr/local/bin/proxy_params.sh
9+
RUN mkdir -p /etc/share/rootCA /etc/mkcert && \
10+
chmod +x /usr/local/bin/fcgi_params.sh /usr/local/bin/proxy_params.sh && \
11+
/usr/local/bin/fcgi_params.sh && \
12+
/usr/local/bin/proxy_params.sh
13+
EXPOSE 80 443
14+
CMD ["nginx", "-g", "daemon off;"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Infocyph
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

scripts/fcgi-params.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
FASTCGI_PARAMS_FILE="/etc/nginx/fastcgi_params"
4+
5+
# Declare required headers
6+
declare -A fastcgi_params=(
7+
["HTTP_CLIENT_IP"]='$http_client_ip'
8+
["HTTP_X_FORWARDED_FOR"]='$http_x_forwarded_for'
9+
["HTTP_CF_CONNECTING_IP"]='$http_cf_connecting_ip'
10+
["HTTP_FASTLY_CLIENT_IP"]='$http_fastly_client_ip'
11+
["HTTP_TRUE_CLIENT_IP"]='$http_true_client_ip'
12+
["HTTP_AKAMAI_EDGE_CLIENT_IP"]='$http_akamai_edge_client_ip'
13+
["HTTP_X_AZURE_CLIENTIP"]='$http_x_azure_clientip'
14+
["HTTP_X_APPENGINE_USER_IP"]='$http_x_appengine_user_ip'
15+
["HTTP_X_REAL_IP"]='$http_x_real_ip'
16+
["HTTP_X_CLUSTER_CLIENT_IP"]='$http_x_cluster_client_ip'
17+
# ["HTTP_X_FLY_CLIENT_IP"]='$fly_client_ip'
18+
["HTTP_ALI_CLIENT_IP"]='$http_ali_client_ip'
19+
["HTTP_X_ORACLE_CLIENT_IP"]='$http_x_oracle_client_ip'
20+
["HTTP_X_STACKPATH_EDGE_IP"]='$http_x_stackpath_edge_ip'
21+
["HTTP_USER_AGENT"]='$http_user_agent'
22+
["HTTP_ACCEPT"]='$http_accept'
23+
["HTTP_ACCEPT_LANGUAGE"]='$http_accept_language'
24+
["HTTP_REFERER"]='$http_referer'
25+
["SERVER_ADDR"]='$server_addr'
26+
["SERVER_PORT"]='$server_port'
27+
["SERVER_PROTOCOL"]='$server_protocol'
28+
["SERVER_NAME"]='$server_name'
29+
["DOCUMENT_ROOT"]='$document_root'
30+
["REQUEST_SCHEME"]='$scheme'
31+
["REQUEST_METHOD"]='$request_method'
32+
["REQUEST_URI"]='$request_uri'
33+
["QUERY_STRING"]='$query_string'
34+
["REMOTE_ADDR"]='$remote_addr'
35+
["REMOTE_PORT"]='$remote_port'
36+
["REMOTE_USER"]='$remote_user'
37+
)
38+
39+
# Check and append missing headers in fastcgi_params
40+
for key in "${!fastcgi_params[@]}"; do
41+
if ! grep -q "^fastcgi_param $key " "$FASTCGI_PARAMS_FILE"; then
42+
echo "Adding missing FastCGI param: $key"
43+
echo "fastcgi_param $key ${fastcgi_params[$key]};" >> "$FASTCGI_PARAMS_FILE"
44+
fi
45+
done
46+
47+
echo "✅ FastCGI parameters updated"
48+
rm -f -- "$0"

scripts/proxy-params.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
# Define the output file location
4+
PROXY_PARAMS_FILE="/etc/nginx/proxy_params"
5+
6+
# Backup existing file if it exists
7+
if [[ -f "$PROXY_PARAMS_FILE" ]]; then
8+
cp "$PROXY_PARAMS_FILE" "${PROXY_PARAMS_FILE}.bak"
9+
fi
10+
11+
# Write the proxy parameters to the file
12+
cat <<EOF > "$PROXY_PARAMS_FILE"
13+
# Essential Proxy Headers
14+
proxy_set_header Host \$host;
15+
proxy_set_header X-Real-IP \$remote_addr;
16+
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
17+
proxy_set_header X-Forwarded-Proto \$scheme;
18+
19+
# Forwarding Additional Headers
20+
proxy_set_header HTTP_CLIENT_IP \$http_client_ip;
21+
proxy_set_header HTTP_X_FORWARDED_FOR \$http_x_forwarded_for;
22+
proxy_set_header HTTP_CF_CONNECTING_IP \$http_cf_connecting_ip;
23+
proxy_set_header HTTP_FASTLY_CLIENT_IP \$http_fastly_client_ip;
24+
proxy_set_header HTTP_TRUE_CLIENT_IP \$http_true_client_ip;
25+
proxy_set_header HTTP_AKAMAI_EDGE_CLIENT_IP \$http_akamai_edge_client_ip;
26+
proxy_set_header HTTP_X_AZURE_CLIENTIP \$http_x_azure_clientip;
27+
proxy_set_header HTTP_X_APPENGINE_USER_IP \$http_x_appengine_user_ip;
28+
proxy_set_header HTTP_X_REAL_IP \$http_x_real_ip;
29+
proxy_set_header HTTP_X_CLUSTER_CLIENT_IP \$http_x_cluster_client_ip;
30+
proxy_set_header HTTP_ALI_CLIENT_IP \$http_ali_client_ip;
31+
proxy_set_header HTTP_X_ORACLE_CLIENT_IP \$http_x_oracle_client_ip;
32+
proxy_set_header HTTP_X_STACKPATH_EDGE_IP \$http_x_stackpath_edge_ip;
33+
proxy_set_header HTTP_USER_AGENT \$http_user_agent;
34+
proxy_set_header HTTP_ACCEPT \$http_accept;
35+
proxy_set_header HTTP_ACCEPT_LANGUAGE \$http_accept_language;
36+
proxy_set_header HTTP_REFERER \$http_referer;
37+
38+
# Essential Server Headers
39+
proxy_set_header SERVER_ADDR \$server_addr;
40+
proxy_set_header SERVER_PORT \$server_port;
41+
proxy_set_header SERVER_NAME \$server_name;
42+
proxy_set_header REMOTE_ADDR \$remote_addr;
43+
proxy_set_header REMOTE_PORT \$remote_port;
44+
proxy_set_header REMOTE_USER \$remote_user;
45+
EOF
46+
47+
# Display confirmation message
48+
echo "✅ Proxy parameters successfully written to $PROXY_PARAMS_FILE"
49+
rm -f -- "$0"

0 commit comments

Comments
 (0)