Skip to content

Commit 614be2b

Browse files
author
Ignacio Van Droogenbroeck
committed
Add nginx configuration to fix 403 errors on direct links
- Added nginx.conf with proper try_files directive for Docusaurus routing - Updated docker-compose.yml to mount nginx.conf - Updated GitHub Actions to deploy nginx.conf alongside docker-compose.yml - Fixes 403 errors when accessing docs pages directly
1 parent b46004b commit 614be2b

3 files changed

Lines changed: 36 additions & 4 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ jobs:
9999
if [ $? -ne 0 ]; then echo "File sync failed"; exit 1; fi
100100
shell: bash
101101

102-
- name: Copy docker-compose.yml to server
102+
- name: Copy docker-compose.yml and nginx.conf to server
103103
run: |
104104
set -x
105-
echo "Copying docker-compose.yml to server..."
106-
scp docker-compose.yml ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }}:${{ secrets.DEPLOY_PATH }}/
107-
if [ $? -ne 0 ]; then echo "Failed to copy docker-compose.yml"; exit 1; fi
105+
echo "Copying docker-compose.yml and nginx.conf to server..."
106+
scp docker-compose.yml nginx.conf ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }}:${{ secrets.DEPLOY_PATH }}/
107+
if [ $? -ne 0 ]; then echo "Failed to copy files"; exit 1; fi
108108
shell: bash
109109

110110
- name: Deploy docs with Docker Compose

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ services:
77
restart: unless-stopped
88
volumes:
99
- /opt/services/docs.basekick.net:/usr/share/nginx/html:ro
10+
- /opt/services/docs.basekick.net/nginx.conf:/etc/nginx/conf.d/default.conf:ro
1011
networks:
1112
- traefik
1213
labels:

nginx.conf

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
server {
2+
listen 80;
3+
server_name docs.basekick.net;
4+
root /usr/share/nginx/html/build;
5+
index index.html;
6+
7+
# Enable gzip compression
8+
gzip on;
9+
gzip_vary on;
10+
gzip_min_length 1024;
11+
gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json;
12+
13+
# Cache static assets
14+
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
15+
expires 1y;
16+
add_header Cache-Control "public, immutable";
17+
}
18+
19+
# Try to serve file directly, fallback to index.html for client-side routing
20+
location / {
21+
try_files $uri $uri/ $uri.html /404.html;
22+
}
23+
24+
# Disable directory listing
25+
autoindex off;
26+
27+
# Security headers
28+
add_header X-Frame-Options "SAMEORIGIN" always;
29+
add_header X-Content-Type-Options "nosniff" always;
30+
add_header X-XSS-Protection "1; mode=block" always;
31+
}

0 commit comments

Comments
 (0)