Skip to content

Commit f9d97bf

Browse files
authored
Merge pull request #181 from refactor-group/167-add-myrefactorcom-domain-and-ssl-cert
Implement changes to switch primary domain to be myrefactor.com
2 parents a4f9352 + abe8754 commit f9d97bf

File tree

3 files changed

+52
-8
lines changed

3 files changed

+52
-8
lines changed

docker-compose.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ services:
1616
# Mount your letsencrypt SSL certs
1717
- /etc/letsencrypt/live/refactor.engineer/:/etc/letsencrypt/live/refactor.engineer/:ro
1818
- /etc/letsencrypt/archive/refactor.engineer/:/etc/letsencrypt/archive/refactor.engineer/:ro
19+
- /etc/letsencrypt/live/myrefactor.com/:/etc/letsencrypt/live/myrefactor.com/:ro
20+
- /etc/letsencrypt/archive/myrefactor.com/:/etc/letsencrypt/archive/myrefactor.com/:ro
1921
- ${SSL_DHPARAMS_PATH}:/etc/letsencrypt/ssl-dhparams.pem:ro
2022
# For SSL certbot renewal
2123
- ./nginx/html:/var/www/html:ro

nginx/conf.d/refactor-platform.conf

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Site-specific configuration for refactor.engineer
1+
# Primary domain configuration for myrefactor.com
2+
# refactor.engineer will redirect to myrefactor.com
23

34
# Use Docker's internal DNS resolver
45
resolver 127.0.0.11 valid=30s;
@@ -15,7 +16,7 @@ upstream frontend {
1516
# Redirect all HTTP traffic to HTTPS
1617
server {
1718
listen 80;
18-
server_name refactor.engineer www.refactor.engineer;
19+
server_name myrefactor.com www.myrefactor.com refactor.engineer www.refactor.engineer;
1920

2021
# Allow Let's Encrypt ACME challenge
2122
location /.well-known/acme-challenge/ {
@@ -24,11 +25,20 @@ server {
2425

2526
# Redirect everything else to HTTPS
2627
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
2737
return 301 https://$host$request_uri;
2838
}
2939
}
3040

31-
# Main HTTPS server block
41+
# Redirect HTTPS refactor.engineer to myrefactor.com
3242
server {
3343
listen 443 ssl;
3444
http2 on;
@@ -41,6 +51,40 @@ server {
4151
# Additional SSL security
4252
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
4353

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+
4488
# HSTS (HTTP Strict Transport Security)
4589
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
4690

@@ -70,8 +114,7 @@ server {
70114

71115
# Handle CORS preflight requests
72116
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;
75118
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE, PATCH' always;
76119
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization,x-version' always;
77120
add_header 'Access-Control-Allow-Credentials' 'true' always;
@@ -82,8 +125,7 @@ server {
82125
}
83126

84127
# 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;
87129
add_header 'Access-Control-Allow-Credentials' 'true' always;
88130
}
89131

web/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub async fn init_server(app_state: AppState) -> Result<()> {
6363

6464
if app_state.config.is_production() {
6565
info!("Server starting... listening for internal connections on http://{host}:{port}");
66-
info!("External access available via HTTPS proxy at https://refactor.engineer");
66+
info!("External access available via HTTPS proxy at https://myrefactor.com");
6767
} else {
6868
info!("Server starting... listening for connections on http://{host}:{port}");
6969
}

0 commit comments

Comments
 (0)