1
- # Site-specific configuration for refactor.engineer
1
+ # Primary domain configuration for myrefactor.com
2
+ # refactor.engineer will redirect to myrefactor.com
2
3
3
4
# Use Docker's internal DNS resolver
4
5
resolver 127.0.0.11 valid=30s;
@@ -15,7 +16,7 @@ upstream frontend {
15
16
# Redirect all HTTP traffic to HTTPS
16
17
server {
17
18
listen 80;
18
- server_name refactor.engineer www.refactor.engineer;
19
+ server_name myrefactor.com www.myrefactor.com refactor.engineer www.refactor.engineer;
19
20
20
21
# Allow Let's Encrypt ACME challenge
21
22
location /.well-known/acme-challenge/ {
@@ -24,11 +25,20 @@ server {
24
25
25
26
# Redirect everything else to HTTPS
26
27
location / {
28
+ # Redirect refactor.engineer to myrefactor.com
29
+ if ($host ~* ^(www\.)?refactor\.engineer$) {
30
+ return 301 https://myrefactor.com$request_uri;
31
+ }
32
+ # Redirect www.myrefactor.com to myrefactor.com
33
+ if ($host = www.myrefactor.com) {
34
+ return 301 https://myrefactor.com$request_uri;
35
+ }
36
+ # Default redirect to HTTPS
27
37
return 301 https://$host$request_uri;
28
38
}
29
39
}
30
40
31
- # Main HTTPS server block
41
+ # Redirect HTTPS refactor.engineer to myrefactor.com
32
42
server {
33
43
listen 443 ssl;
34
44
http2 on;
@@ -41,6 +51,40 @@ server {
41
51
# Additional SSL security
42
52
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
43
53
54
+ # Permanent redirect to myrefactor.com
55
+ return 301 https://myrefactor.com$request_uri;
56
+ }
57
+
58
+ # Redirect www.myrefactor.com to myrefactor.com
59
+ server {
60
+ listen 443 ssl;
61
+ http2 on;
62
+ server_name www.myrefactor.com;
63
+
64
+ # SSL Certificate configuration
65
+ ssl_certificate /etc/letsencrypt/live/myrefactor.com/fullchain.pem;
66
+ ssl_certificate_key /etc/letsencrypt/live/myrefactor.com/privkey.pem;
67
+
68
+ # Additional SSL security
69
+ ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
70
+
71
+ # Redirect to non-www
72
+ return 301 https://myrefactor.com$request_uri;
73
+ }
74
+
75
+ # Main HTTPS server block for myrefactor.com (primary domain)
76
+ server {
77
+ listen 443 ssl;
78
+ http2 on;
79
+ server_name myrefactor.com;
80
+
81
+ # SSL Certificate configuration
82
+ ssl_certificate /etc/letsencrypt/live/myrefactor.com/fullchain.pem;
83
+ ssl_certificate_key /etc/letsencrypt/live/myrefactor.com/privkey.pem;
84
+
85
+ # Additional SSL security
86
+ ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
87
+
44
88
# HSTS (HTTP Strict Transport Security)
45
89
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
46
90
@@ -70,8 +114,7 @@ server {
70
114
71
115
# Handle CORS preflight requests
72
116
if ($request_method = 'OPTIONS') {
73
- add_header 'Access-Control-Allow-Origin' 'https://refactor.engineer' always;
74
- add_header 'Access-Control-Allow-Origin' 'https://www.refactor.engineer' always;
117
+ add_header 'Access-Control-Allow-Origin' 'https://myrefactor.com' always;
75
118
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE, PATCH' always;
76
119
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization,x-version' always;
77
120
add_header 'Access-Control-Allow-Credentials' 'true' always;
@@ -82,8 +125,7 @@ server {
82
125
}
83
126
84
127
# Add CORS headers for actual requests
85
- add_header 'Access-Control-Allow-Origin' 'https://refactor.engineer' always;
86
- add_header 'Access-Control-Allow-Origin' 'https://www.refactor.engineer' always;
128
+ add_header 'Access-Control-Allow-Origin' 'https://myrefactor.com' always;
87
129
add_header 'Access-Control-Allow-Credentials' 'true' always;
88
130
}
89
131
0 commit comments