Skip to content

Commit bfb78e0

Browse files
committed
chore: initial commit
0 parents  commit bfb78e0

File tree

7 files changed

+202
-0
lines changed

7 files changed

+202
-0
lines changed

.claude/settings.local.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(ls:*)"
5+
],
6+
"deny": []
7+
}
8+
}

.github/workflows/deploy.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Deploy to Batman Server
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code (for access to docker-compose-reverseproxy.yaml and nginx.conf)
13+
uses: actions/checkout@v4
14+
15+
- name: Connect to Tailscale
16+
uses: tailscale/github-action@v2
17+
with:
18+
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
19+
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
20+
tags: tag:batman-ci
21+
22+
- name: Copy nginx.conf to Batman Server
23+
uses: appleboy/scp-action@v0.1.7
24+
with:
25+
source: "docker-compose-reverseproxy.yaml,nginx.conf"
26+
target: /home/${{ secrets.BATMAN_SERVER_USER}}/
27+
host: ${{ secrets.BATMAN_SERVER_IP }}
28+
username: ${{ secrets.BATMAN_SERVER_USER }}
29+
key: ${{ secrets.BATMAN_SERVER_SSH_KEY }}
30+
31+
- name: Deploy to Batman Server
32+
uses: appleboy/ssh-action@v0.1.0
33+
with:
34+
host: ${{ secrets.BATMAN_SERVER_IP }}
35+
username: ${{ secrets.BATMAN_SERVER_USER }}
36+
key: ${{ secrets.BATMAN_SERVER_SSH_KEY }}
37+
port: 22
38+
script: |
39+
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
40+
docker compose -f docker-compose-reverseproxy.yaml up -d
41+
42+
- name: List and remove non-latest images in Batman Server
43+
uses: appleboy/ssh-action@v0.1.0
44+
with:
45+
host: ${{ secrets.BATMAN_SERVER_IP }}
46+
username: ${{ secrets.BATMAN_SERVER_USER }}
47+
key: ${{ secrets.BATMAN_SERVER_SSH_KEY }}
48+
port: 22
49+
script: |
50+
images=$(docker images --format '{{.Repository}}:{{.Tag}} {{.ID}}' | grep -v ':latest')
51+
echo "Images to be removed:"
52+
echo "$images"
53+
54+
while IFS= read -r image; do
55+
repo_tag=$(echo $image | awk '{print $1}')
56+
image_id=$(echo $image | awk '{print $2}')
57+
echo "Removing image $repo_tag with ID $image_id"
58+
docker rmi "$image_id" || true
59+
done <<< "$images"

CLAUDE.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
This is a Docker-based Nginx reverse proxy for the Batman server that handles SSL termination and routing for multiple domains including eduardovedes.com.
8+
9+
## Architecture
10+
11+
- **nginx.conf**: Main Nginx configuration file that defines server blocks for each domain
12+
- **docker-compose-reverseproxy.yaml**: Docker Compose configuration for the Nginx reverse proxy container
13+
- **SSL certificates**: Mounted from ./ssl/{domain}/ directories containing fullchain.pem and privkey.pem files
14+
- **External network**: Uses 'batmanvps' external Docker network to communicate with backend services
15+
16+
## Common Commands
17+
18+
```bash
19+
# Start the reverse proxy
20+
docker-compose -f docker-compose-reverseproxy.yaml up -d
21+
22+
# Stop the reverse proxy
23+
docker-compose -f docker-compose-reverseproxy.yaml down
24+
25+
# View logs
26+
docker-compose -f docker-compose-reverseproxy.yaml logs -f
27+
28+
# Restart Nginx (reload configuration)
29+
docker-compose -f docker-compose-reverseproxy.yaml restart nginx
30+
31+
# Test Nginx configuration syntax
32+
docker exec nginx-reverseproxy nginx -t
33+
```
34+
35+
## Domain Configuration Pattern
36+
37+
Each domain follows this pattern in nginx.conf:
38+
39+
- HTTP (port 80): Redirects to HTTPS
40+
- HTTPS (port 443): SSL termination with proxy_pass to backend services
41+
- Backend services are accessed via Docker network names (e.g., `frontend-{domain}:3000`)
42+
- API endpoints for some domains are routed to separate backend services on port 3001
43+
44+
## SSL Configuration
45+
46+
SSL certificates are expected in ./ssl/{domain}/ directories with:
47+
48+
- fullchain.pem (certificate chain)
49+
- privkey.pem (private key)
50+
51+
All domains use TLSv1.2 and TLSv1.3 with HSTS headers for security.

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) 2024 Eduardo Vedes
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.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# batman-reverse-proxy
2+
3+
A Docker-based Nginx reverse proxy for the Batman dedicated server that handles SSL termination and routing for eduardovedes.com and its subdomains.

docker-compose-reverseproxy.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
services:
2+
nginx:
3+
image: nginx:latest
4+
container_name: nginx-reverseproxy
5+
restart: unless-stopped
6+
ports:
7+
- "80:80"
8+
- "443:443"
9+
volumes:
10+
- ./nginx.conf:/etc/nginx/conf.d/default.conf
11+
- ./ssl/eduardovedes:/etc/nginx/ssl/eduardovedes
12+
networks:
13+
- batmanvps
14+
networks:
15+
batmanvps:
16+
external: true

nginx.conf

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Global SSL session cache
2+
ssl_session_cache shared:SSL:10m;
3+
ssl_session_timeout 10m;
4+
5+
# Enable gzip compression
6+
gzip on;
7+
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
8+
9+
server {
10+
listen 80;
11+
server_name eduardovedes.com www.eduardovedes.com
12+
13+
access_log /var/log/nginx/http_redirect.access.log;
14+
error_log /var/log/nginx/http_redirect.error.log;
15+
16+
location / {
17+
return 301 https://$host$request_uri;
18+
}
19+
}
20+
21+
server {
22+
listen 443 ssl;
23+
server_name eduardovedes.com www.eduardovedes.com;
24+
client_max_body_size 500M;
25+
26+
access_log /var/log/nginx/eduardovedes.access.log;
27+
error_log /var/log/nginx/eduardovedes.error.log;
28+
29+
ssl_certificate /etc/nginx/ssl/eduardovedes/fullchain.pem;
30+
ssl_certificate_key /etc/nginx/ssl/eduardovedes/privkey.pem;
31+
32+
ssl_protocols TLSv1.2 TLSv1.3;
33+
ssl_prefer_server_ciphers on;
34+
ssl_ciphers HIGH:!aNULL:!MD5;
35+
add_header Strict-Transport-Security "max-age=31536000" always;
36+
37+
location / {
38+
proxy_pass http://frontend-eduardovedes:3000;
39+
proxy_set_header Host $host;
40+
proxy_set_header X-Real-IP $remote_addr;
41+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
42+
proxy_set_header X-Forwarded-Proto $scheme;
43+
}
44+
}

0 commit comments

Comments
 (0)