-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnginx-routing.conf
More file actions
87 lines (74 loc) · 2.92 KB
/
nginx-routing.conf
File metadata and controls
87 lines (74 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# Nginx configuration for routing between Hugo static site and Ghost CMS
# This configuration assumes:
# - Hugo static files are served from /var/www/helen/public
# - Ghost CMS is running on localhost:2368
server {
listen 80;
server_name cybermonkey.net.au www.cybermonkey.net.au;
# Redirect HTTP to HTTPS
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name cybermonkey.net.au www.cybermonkey.net.au;
# SSL configuration (update with your certificates)
ssl_certificate /etc/letsencrypt/live/cybermonkey.net.au/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/cybermonkey.net.au/privkey.pem;
# Root directory for Hugo static files
root /var/www/helen/public;
index index.html;
# Security headers
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Content-Security-Policy "default-src 'self' https:; script-src 'self' 'unsafe-inline' 'unsafe-eval' https:; style-src 'self' 'unsafe-inline' https:;" always;
# Ghost CMS routes
location /blog {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://localhost:2368;
proxy_redirect off;
}
# Ghost admin panel
location /ghost {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://localhost:2368;
proxy_redirect off;
}
# Ghost API routes
location ~ ^/blog/(content|members|admin|api) {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://localhost:2368;
proxy_redirect off;
}
# Ghost assets
location /content/images {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://localhost:2368;
proxy_redirect off;
}
# Hugo static site (all other routes)
location / {
try_files $uri $uri/ @hugo_404;
}
# Hugo 404 handler
location @hugo_404 {
try_files /404.html =404;
}
# Gzip compression
gzip on;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml application/json;
gzip_vary on;
}