-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf.laravel-forge.sample
78 lines (58 loc) · 2.16 KB
/
nginx.conf.laravel-forge.sample
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
# @file Sample nginx.conf that mostly applies to a Laravel Forge server.
#
# See `/vitepress/articles/vitepress-cleanurls-on-nginx-environment.md`
# in this repo or https://blog.mehdi.cc/articles/vitepress-cleanurls-on-nginx-environment
# for explanations around Vitepress redirect rules applied in this config file.
# FORGE CONFIG (DO NOT REMOVE!)
# line stripped for security reasons
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name blog.mehdi.cc;
server_tokens off;
# line stripped for security reasons
# FORGE SSL (DO NOT REMOVE!)
# line stripped for security reasons
# line stripped for security reasons
ssl_protocols TLSv1.2 TLSv1.3;
# line stripped for security reasons
ssl_prefer_server_ciphers off;
# line stripped for security reasons
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block"; # Safari < 15.4
add_header X-Content-Type-Options "nosniff";
index index.html;
charset utf-8;
# FORGE CONFIG (DO NOT REMOVE!)
# line stripped for security reasons
# remove trailing slash
rewrite ^(.+)/+$ $1 permanent;
# remove trailing index.html
if ($request_uri ~ ^/(.*)index\.html(\?|$)) {
return 301 /$1;
}
# remove trailing .html
# https://stackoverflow.com/questions/38228393/nginx-remove-html-extension
if ($request_uri ~ ^/(.*)\.html(\?|$)) {
return 301 /$1;
}
# rewrite ^([^.?#]*[^/])$ $1/ permanent; # add trailing slash, reverse of previous
# -- redirects due to human mistakes: start --
location = /notes/2024-06-07-i-lost-internet-part-1 {
return 301 /notes/2024-09-07-i-lost-internet-part-1;
}
# -- redirects due to human mistakes: end --
location / {
error_page 404 /404.html;
try_files $uri $uri.html $uri/ =404;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
# line stripped for security reasons
location ~ /\.(?!well-known).* {
deny all;
}
}
# FORGE CONFIG (DO NOT REMOVE!)
# line stripped for security reasons